![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Spliting file based on condition | Raamc | Shell Programming and Scripting | 2 | 05-15-2008 11:51 AM |
| How to split the String based on condition? | sankar reddy | Shell Programming and Scripting | 2 | 03-19-2008 07:48 AM |
| command for deleting log files based on some condition | pulkit | Shell Programming and Scripting | 4 | 01-09-2008 06:17 AM |
| Read file based on condition | sbasetty | Shell Programming and Scripting | 5 | 02-01-2007 02:54 AM |
| Splitting a file based on some condition and naming them | srivsn | Shell Programming and Scripting | 1 | 12-07-2005 11:27 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Folks;
I'm trying to write a script to scan through a directory tree then for each file it finds, it run a command line tool, then if the results include the word "DONE", it removes the file. In more details; i have a Linux directory tree such as "/opt/grid/1022/store" I'm trying to write a script going through this tree and every file it finds, it should run this command on it: /opt/dev/chktool -getstat file_name |grep -v "DONE" If the output include the word "DONE" then we need to remove it, if not, skip to the next one. Any help is greatly appreciated |
|
||||
|
You may never get "DONE" because you are using grep -v.
If I understood your query properly, you probably need this... Code:
for file_name in `find . -name 'pattern' -print`
do
if [[ `/opt/dev/chktool -getstat $file_name |grep -c "DONE"` -gt 0 ]]; then
#rm $file_name
fi
done
|
|
||||
|
I still see "file_name" in the if statement.
I think i didn't explain it better, What i'm looking for is to go through the directory tree, find any file under any subdirectory then run the tool on it, if the output include the word "DONE" then remove the file, if not, leave the file alone and go to the next file and do the same thing. I hope that makes it more clear |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|