If all the files are in the same directory, it can be done easily by something like:
cd path/to
for i in *.txt; do grep 'something' "$i" >"path/to-somewhere-else/$i"; done
Frage
Sorry for my basic question, but I have >1000 text files in a folder. Is it a way of running the same command on all files and automatically output the new files to a different folder and giving them the same name as they had?
I.e.
grep 'something' path/to/file.txt > path/to-somewhere-else/file.txt
Thank you!
Lösung
If all the files are in the same directory, it can be done easily by something like:
cd path/to
for i in *.txt; do grep 'something' "$i" >"path/to-somewhere-else/$i"; done