Find the answer to your Linux question:
Results 1 to 3 of 3
Hi guys,i could like to append the sentence to the next line when it hit a certain key word,could anyone help out? Input file: root: root time_last_login = 1191232080 root ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    25

    Unhappy Appending problem

    Hi guys,i could like to append the sentence to the next line when it hit a certain key word,could anyone help out?

    Input file:

    root: root time_last_login = 1191232080 root tty_last_login = /dev/vty0 root host_last_login = rep1nim root unsuccessful_login_count = 0 root time_last_unsuccessful_login = 1183617892 root tty_last_unsuccessful_login = /dev/vty0 root host_last_unsuccessful_login = rep1nim

    i could like it to append to the next line when it see the word "root",hope someone can help..been trying out alot of source code..but still cant do it..can sed or awk do it?cos i only got this 2 program

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I'm afraid that I don't understand the problem. Can you give a simplified example, or maybe explain it more thoroughly?
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined! cfajohnson's Avatar
    Join Date
    May 2007
    Location
    Toronto, Canada
    Posts
    52
    Quote Originally Posted by cyberray View Post
    Hi guys,i could like to append the sentence to the next line when it hit a certain key word,could anyone help out?

    Input file:

    root: root time_last_login = 1191232080 root tty_last_login = /dev/vty0 root host_last_login = rep1nim root unsuccessful_login_count = 0 root time_last_unsuccessful_login = 1183617892 root tty_last_unsuccessful_login = /dev/vty0 root host_last_unsuccessful_login = rep1nim

    i could like it to append to the next line when it see the word "root",hope someone can help..been trying out alot of source code..but still cant do it..can sed or awk do it?cos i only got this 2 program
    Code:
    awk '{print}
        /root/ { print "Line to be appended" }' FILE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...