Replace all spaces by,
Posted on 2011-03-15
Can I get a perl script that can convert the following output into CSV. So basically all the spaces need to be converted to a comma.
My goal is to run a cron job every day and then add the output of df-h into a CSV file every day. I need to script.
Script 1 will just convert this output to CSV
Script 2 will open a file everyday for append and then it will issue the df -h command then store the output of df -h into a CSV file everyday and it will skip the headers. Also can the perl script get the hostname of the machine also and then add it as a column to the csv and repeat the hostname in the CSV every day ?
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 15G 4.0G 9.8G 29% /
/dev/sda6 27G 6.9G 19G 28% /omega
/dev/sda3 4.9G 390M 4.3G 9% /var
/dev/sda5 4.9G 139M 4.5G 3% /tmp
tmpfs 127G 0 127G 0% /dev/shm
/dev/sdb2 35G 15G 19G 44% /alpha
/dev/sdc1 135G 28G 100G 22% /alpha1
/dev/sdd1 135G 105G 23G 83% /alpha2