![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Pick up the return code for every iteration and display the result only once in loop. | manas6 | Shell Programming and Scripting | 1 | 10-21-2008 08:12 AM |
| How to negate grep result? | mmdawg | Shell Programming and Scripting | 4 | 05-05-2008 09:24 AM |
| diaplaying the grep result | rag84dec | Shell Programming and Scripting | 1 | 03-27-2008 02:37 AM |
| append a string to a grep result | melanie_pfefer | Shell Programming and Scripting | 8 | 03-19-2008 07:19 AM |
| grep to handle a 0 result | ocelot | UNIX for Dummies Questions & Answers | 6 | 02-05-2007 11:19 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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? |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|