My script(3 arguments $1 = folder,$2 extension,$3 string) should do the following things:
-Enter in the folder of $1(if exists).
-Put ls *.$2 > temp.txt ( I use a temp file to store the result of ls command and if $2 = txt in this file I'll have all the .txt files of the folder)
-Now I want to return a list of files where the string $3 exists.
>temp.txt
>temp2.txt
ls *.$2 > temp.txt
cat temp.txt | head -1 |grep "$3" > temp2.txt
cat temp2.txt
But it doesn't print anything.
I'd like to sort the temp file with the .$2 extensions by lines and with a loop grep every line(if $? of grep returns 0 a put the file on the result file).
Maybe there are quickest method to do this but I want some script easy to understand(I don't know a lot of commands).