LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Row manipulation with awk (https://www.linuxquestions.org/questions/linux-newbie-8/row-manipulation-with-awk-767200/)

SHIFTA 11-05-2009 10:27 PM

Row manipulation with awk
 
Hi guys,

I want to move (cut) the second row onto the first using awk. I show you what I mean:



test
test1


Basically, I want to move "test1" next to "test"

test test1


Cheers,

Sam

pixellany 11-05-2009 10:37 PM

To get the right logic, you need to show more of the file content. e.g. will you do the stated action ONLY when you find "test" on one line?

If it is that simple, then:

Code:

sed '/^test$/{N;s/\n/ /}' filename > newfilename
If finding the word "test" alone on a line, then append the next line and strip out the newline character. Write the result to "newfilename"


All times are GMT -5. The time now is 11:23 AM.