How to edit next line after pattern using sed?
Using sed, how do I search for a line ending with foo and then edit the next line if it starts with #bar?
Using sed, how do I search for a line ending with foo and then edit the next line if it starts with #bar?
I have some text files, and I’d like to be able to move an arbitrary line in any of the files up or down one line (lines at the beginning or end of the file would stay where they are). I have some working code but it seems kludgy and I’m not convinced I have all the edge cases covered, so I’m wondering if there’s some tool or paradigm that does this better (e.g. easier to understand the code (for other readers or me in 6 months), easier to debug, and easier to maintain; “more efficient” isn’t very important).
Using a common command line tool like sed or awk, is it possible to join all lines that end with a given character, like a backslash?
I’m trying to use sed to edit a config file. There are a few lines I’d like to change. I know that under Linux sed -i allows for in place edits but it requires you save to a backup file. However I would like to avoid having multiple backup files and make all my in place changes at once.
The s command can be followed by zero or more of the following flags:
I’m a relative Linux novice. Suppose that I have a text file a.txt that contains the following text:
I have a directory full of XML files that look like this, for which I want to change the value of the “offset” element number from 1 to some other number
The few, the brave.
I am looking for away contact lines based on the next line. So far the only way I see is to create a shell script that will read line by line and will do something along these lines:
./sample.txt Specimen_before.TXT ./sample.TXT Specimen_after.TXT