|
Any way to grep a string in directories and return the result with diskusage aswell?
What Im basically trying to do is this:
I have a small script that can grep any parameter entered into a search string, then print to the screen the name of each file the parameter appears in as well as the file path, ie the directory.
The code Im using just for this is....
Directory
---------
1. Search /export/home/btch1/nelse2
Enter Choice number ( press q to quit ) :\c"
read choice
case $choice in
1)
echo "------------------------------"
echo "Searching /xxxx/xxxx"
echo "------------------------------"
echo $string
grep -li "$string" $DIRECTORY/*
echo "--------------------------------------"
echo " Displaying directory size"
echo "--------------------------------------"
df -k .
;;
*)
Which brings up the results as follows
Searching /xxxx/xxxx
------------------------------
2005
/export/home/btch1/nelse2/PR_MX_INT_0001_20080917180857.dat
/export/home/btch1/nelse2/Search2.ksh
--------------------------------------
Displaying directory size
--------------------------------------
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/bootdg/rootvol
10080200 7323251 2656147 74% /
What I would like though is for the 2 resulting files displayed to have thier filesize before or after aswell, for example
1288 /export/home/btch1/nelse2/Search2.ksh
ive tried putting du before the grep and piping to the rest of the code, but it either doesnt work or just prints the filesize and not the file name, or just the filesize and not the filename, so the likes of
du - sk | grep -li "$string" $DIRECTORY/*
doesn't work
Can anyone help?
|