luft
August 6, 2008, 11:48am
1
Hello all,
I have the following 2 questions..
1) I would like to capture the output of an echo command to 2 different files at the same time. This does not seem to work. Any ideas?
echo ==== started on `date` ==== >> res1.log res2.log
2) Would it be possible to just get the 5th and 6th column of df -k output as listed below?
use% Mounted on
10 /d1
20 /d2
Thanks
Use awk to get it.
df -k | awk '{ print $5 " " $6}'
What you want capture in 2 different files ?
You can use for loop with 2 iterations to echo to 2 different files.
luft
August 6, 2008, 12:24pm
3
Thanks Ynilesh for the quick response..I already tried using awk but as my df output is slightly different, I don't get the expected output as some of the FileSystem names are slightly longer.
df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
10157368 972328 8660752 11% /
/dev/sda3 248895 18257 217786 8% /boot
tmpfs 33028244 0 33028244 0% /dev/shm
/dev/sda5 10153988 154352 9475520 2% /home
/dev/sda7 10153988 154928 9474944 2% /opt
/dev/sda6 10153988 157852 9472020 2% /tmp
/dev/sda9 10153988 4591136 5038736 48% /usr
/dev/sda8 10153988 325752 9304120 4% /var
/dev/mapper/VolApp-App
102180192 10133068 86856676 11% /app
/dev/mapper/VolDB-IOLDevData
411817200 297404052 93494060 77% /d1
/dev/mapper/VolDBbkp-IOLDevbkp
102180192 192264 96797480 1% /d15
df -k | awk '{ print $5 " " $6}'
Use% Mounted
/
8% /boot
0% /dev/shm
2% /home
2% /opt
2% /tmp
48% /usr
4% /var
/app
/d1
/d15