![]() |
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 |
| How to remove directory with subdirectories and files? | ppa108 | UNIX for Dummies Questions & Answers | 9 | 11-25-2008 02:02 AM |
| searching content of files in the current and sub directories | tiger99 | Shell Programming and Scripting | 4 | 01-23-2008 03:11 AM |
| list largest files in a directory & its subdirectories | igidttam | UNIX for Dummies Questions & Answers | 6 | 09-25-2006 11:31 AM |
| Searching for files over 30 days old in current directory | cxredd4 | Shell Programming and Scripting | 18 | 06-11-2006 02:16 AM |
| Searching files within subdirectories | jalvarez | UNIX for Dummies Questions & Answers | 1 | 09-08-2003 04:12 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
i want to make a bash script that searches a specific pattern in files through all subdirectories beneath the current directory..without using the command grep-R
but only the command grep.. e.g for i in * do grep "pattern" $i ..... ... done using the character (*) the script searches only in files beneath the current directory...how can i make it????? any help would be appreciated ![]() |
|
||||
|
thanks for your reply..but i asked something else...
my code is: if [ $# -eq 1 ] then echo "give the parameter" exit 1 fi for i in * do grep "$1" $i if [ $? -eq 0 ] then echo "File $i" grep $1 $i fi done when i run this script...the message is segmentation fault.. what is the problem...??? |
|
|||||
|
Milagros,
I hope this is not a homework -- it smells like it. In any event, here is your shell corrected: Code:
if [ $# -ne 1 ]
then
echo "give the parameter"
exit 1
fi
for i in *
do
mTot=`grep -c ${1} $i`
if [ ${mTot} -gt 0 ]
then
echo "File $i"
fi
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|