![]() |
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 |
| Couldn't set locale correctly | Mr Pink | SUN Solaris | 7 | 03-03-2009 08:16 AM |
| HP-UX will not boot correctly | pantas manik | HP-UX | 1 | 05-30-2006 02:51 AM |
| HP-UX will not boot correctly | intern | UNIX for Dummies Questions & Answers | 5 | 05-24-2006 08:19 AM |
| Couldn't set locale correctly | mattd | UNIX for Dummies Questions & Answers | 1 | 02-10-2004 05:11 PM |
| why the PATH can not be set correctly? | yishen | UNIX for Dummies Questions & Answers | 5 | 07-23-2002 10:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
My goal is to find files contain the "signal 11" string in a specific directory. I need the file details followed by the string.
I wrote a script to test out and play with Shell command since it's my first time to write a Shell script. Let me cut the story short... this command line: if [ 'grep -i "signal 11" $fil' -ne "" ] returns nothing, but actually in reality, I have couple files contains "signal 11" string. My question is, why does the script not return a list of files which contains "signal 11"? Is there anything wrong with my script that you can see? Thanks in advance! ========================================== #!/bin/sh # RESULT=/disk2/app/applmgr/appltop/cssm_custom/11.5.0/out/W2.out if [ -f /disk2/app/applmgr/appltop/cssm_custom/11.5.0/out/W2.out ] then rm $RESULT fi #List all modified files more then 7 days in the Directory for fil in `find /disk2/app/applmgr/comntop/admin/log/ARDEV_arebdd -type f -mtime +7` do #Check if the file contains "signal 11" #If Yes, print out the file name to the output file. if [ 'grep -i "signal 11" $fil' -ne "" ] then echo "fil = $fil" >> $RESULT fi done =============================================== |
|
||||
|
if your grep supports -l (no need to use if/else )
Code:
grep -l pattern $fil >> out Code:
awk '/pattern/{print FILENAME;exit}' $file >> out
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|