Saturday, 15 September 2012

linux - Trying to create a file to call another file for a looped search -


I am trying to write a script that calls the second script and uses it once or in a loop Inputs

I wrote a script that searches for a file for only one file and then prints the name of the file and gives the list of rows that are searched. That script is here

  #! / Bin / bash if [[$ # $ lt; 2]] Then echo "Error": 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 "  

So now I write a new script I want to say that the user enters only one file in the form of a second argument, and he will also loop all the files in the directory and search.

So if there is an input:

  ./testcript if testfile   

This will only use the script but if the input is:

  ./script if the desktop < / Code>  

This is all the files in a loop

For eternity, let's go for all of you in my heart.

Something can do such a thing:

  #! / Bin / bash do_for_file () {grep "$ 1" "$ 2"} Do_for_dir () {cd "$ 2" | | Exit file for 1 * do_for "$ 1" "CD file" for "$ file."} Do_for () {where = "file" [[-d "$ 2"] & amp; amp; where = Dir do_for_ $ "$ 1" "$ 2"} "$ 1" "$ 2"    }

No comments:

Post a Comment