I used that ls -bl *.c | grep -r "string"
ls -bl *.c | grep -r "string"
. However, the files in the sub directory are printed as well. How do I print only files that contain the string only in my current directory in Bash shell?
If you want to search for a "string" in all.c files in current directory just pass the files to grep:
grep string *.c
grep -r
ignores standard input and scans current directory recursively. echo ignored | grep -r "string"
echo ignored | grep -r "string"
will work the same way as grep -r "string"
.
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.