Answer the question
In order to leave comments, you need to log in
How to edit multiple text files?
Good afternoon! Help with the task. There is a directory with a large number of text files of the same type (about 450). In each, you need to delete some pattern1, change pattern2 to pattern3. For one file, I found how to do it. what to do for all files in the directory?
Answer the question
In order to leave comments, you need to log in
perl -pi~ -e 's/foo/bar/g' *.html
Well, here's a one-liner.
Replaces foo with bar in all .html files.
Your problem is solved in 3 one-liners.
PS And this one-liner also saves the original files named html~.
uh..
1. get a list of files
2. cycle through them
3. add "the second file to the end of the first, the third to the end of the resulting one, etc."
Long but single line PowerShell
D:\test - folder where files are located
*.txt - file mask
D:\test\out.txt - general glued file after all edits
If Linux then you can just on sh
<code>find /ПАПКА_ОТ КОТОРОЙ_ИСКАТЬ -type f -name "*.html" -exec sed -i 's/FOO/BAR/g' "{}" \;</code>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question