I am able to locate files in a folder containing a specific text string using this command:
grep -lir 'string' ~/directory/*
How do I move the files that appear in the above result to another location?
|
I am able to locate files in a folder containing a specific text string using this command:
How do I move the files that appear in the above result to another location? |
|||
|
|
|
As always, beware of In the Unix philosophy, you use a command to search directories for files, and another one to look at its content. Using GNU tools, I'd do:
But even then, beware of race conditions and possible security issues if you run it as one user on a directory writable by some other user. |
||||
|
|
|
Use
Be careful about files containing special characters (spaces, quotes). If this is your case, filtering the list with An alternative to the third syntax for Another option is command substitution - |
|||||||
|
|
If your file names don't contain any special characters (whitespace or
|
|||||
|