Thread: Joining consecutive lines

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    11

    Thumbs up Joining consecutive lines

    Hi *,

    Can anyone tell me if there is an unix utility to join two consecutive lines ?

    ex:

    $ cat file
    a
    1
    b
    2
    c
    3

    output should be :
    a 1
    b 2
    c 3

    Thanks,
    14341

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    use editor like vim or emacs (i use this) can't think of any direct utility from shell

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    11
    Quote Originally Posted by RockyMarrone View Post
    use editor like vim or emacs (i use this) can't think of any direct utility from shell
    kidding uh!

    Dude i don't want to do it manually.

    As a work around a c/cpp program can be written which can do the job. But i just want to know if i can achieve this with inbuilt unix tools or not.

    Thanks,
    14341

  4. #4
    Registered User
    Join Date
    Aug 2009
    Posts
    11
    Is there any possibility to solve the above problem using awk?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  2. Print out first N lines
    By YoYayYo in forum C Programming
    Replies: 1
    Last Post: 02-21-2008, 12:58 AM
  3. First Consecutive composites Help
    By ch4 in forum C Programming
    Replies: 10
    Last Post: 11-23-2007, 04:55 PM
  4. Line Counting
    By 00Sven in forum C Programming
    Replies: 26
    Last Post: 04-02-2006, 08:59 PM
  5. display 10 consecutive lines...........
    By imbecile in C in forum C Programming
    Replies: 6
    Last Post: 07-09-2003, 07:37 PM

Tags for this Thread