I tried:

grep "$1-2400000" /media/linux/DATADISK/flashka/

It is running and doing nothing for a long time. Is there another way? It is not necessary to do that with the terminal.

  • 3
    Do you want to grep a literal $1 or is this supposed to be a variable to be expanded? – markgraf Mar 12 '20 at 10:59

You're missing a -r to match "all files" and should probably use single-quotes:

grep -r -l -F '$1-2400000' /media/linux/DATADISK/flashka/

With -l, grep will only show you filenames, not the match in the file. -F greps for a fixed string, instead of a regex.

If your filenames contain spaces or other special characters, you may want to make use of find instead:

find /media/linux/DATADISK/flashka/ -type f -exec grep -l -F '$1-2400000' {} \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.