I'm trying to print the name of every C program in a specified directory tree that contains a "goto" command.
In other words, it must print the name of every file that contains "goto" as a word. Here is what I do:
for fullname in `grep -r -l "\<goto\>"./*.c`;
do
echo `basename $fullname`
done
but on running this I only get
"command not found".
Assuming that you want to also search nested directories this should work
for fullname in $(grep -r -l "goto" . | grep ".*\.c$"); do
echo $(basename $fullname)
done
I know this is answered but the following will work for non-nested-directories.
grep "regex" /path/*
which shows
t.txt:Loren ip sum let etum REGEX
v.c:do_regex_match("regex","bleh");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.