Saved Bookmarks
| 1. |
Solve : insert line in text file with loop? |
|
Answer» Hello, looks like homework... but until you prove that it isnt, try to useCode: [Select] for /? in cmd The rule of thumb is "Innocent untill proven guilty", which most people don't seem to follow in here...if you are able to use tools for string processing, such as gawk for windows(see my sig), Code: [Select]C:\test>more file.txt line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 C:\test>gawk "NR%2==0{print;print \"text\";next}1" file.txt line 1 line 2 text line 3 line 4 text line 5 line 6 text line 7 line 8 text line 9 line 10 text the example prints "text" for every 2 lines.I'm actually still trying to figure out what self-respecting school WOULD teach batch.Thanks for the comments so far. I'm not able to use tools like gawk or sed. It isn't possible to use internet on the machine I have to do the task I described. I know it sounds lazy but at the moment I don't have the time to teach myself how to do the trick, so can anybody help me with this? |
|