0

I have a file with foll format:

key1
123
key2
345

I want to get it as:

key1 123
key2 345

I am trying a mix of seds , grep etc but not quite getting what I want. Any suggestions . I think deleteing "\n" on every odd row would also do the trick but can get that to work .

codeObserver
  • 6,333
  • 16
  • 73
  • 119

2 Answers2

6

This is a job for paste

paste -d " " - - < filename
glenn jackman
  • 223,850
  • 36
  • 205
  • 328
3

I think this might work for you:

echo -e "key1\n123\nkey2\n456" | sed 'N;s/\n/ /'
potong
  • 51,370
  • 6
  • 49
  • 80
  • The `N` command appends a newline, then the next line to the current line. The `s/\n/ /` replaces the newline (`\n`) with a space. – potong Dec 09 '11 at 08:13