Friday, July 2, 2010

bash script to create incremental multiple lines in a file

I used this script to create a default file for pxelinux.cfg. It could be used for anything that needs almost identical lines added to a file. In this instance I have multiple esx servers and if I want to install/re-install them using a pxe boot environment all I need to do is select the correct server and off I go!

#!/bin/bash

for i in {001..999}
do
echo "label $i" >> default
echo "menu label $i" >> default
echo "kernel esx/vmlinuz" >> default
echo "append initrd=initrd.img vmkopts=debugLogToSerial:1 mem=512M quiet ks=http://IP_address/kickstart_file" >> default
done

No comments: