I'm having trouble getting a script to do what I want.
I will search a file for a pattern that has a script and print the line numbers and examples of that pattern.
I want to know before writing the file name before printing the lines
I also want to know how to write a new script which it calls a call And will pass two arguments for it.
The first argument is that the pattern and the second place for grep
If the location is a directory, it will loop and will use the script to search the pattern on all the files in the directory.
#! / Bin / bash If [[$ # -ne 2]] then "error" echo: 2 arguments must be provided. Exhaust-1fi if [[! -a $ 2]]; Then "echo" error: the second argument should be a file. "Exit-2f echo" ------ file = "$ 2" ------ "grep -ne" $ 1 "" $ 2 " This script is Using the M, I need new to call, I got a lot of help in asking a similar question, but I still lost. I know that I use the -d command to test the directory. I can do it and then use 'for' loop on command, but actually how is panning for me.
me It seems that you want to add the -H option to grep: -H, --with-filename Print the file name for each match This is the default There are multiple files to search.
No comments:
Post a Comment