LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Closed Thread
 
Search this Thread
Old 02-24-2012, 07:22 AM   #1
bnbhp0
LQ Newbie
 
Registered: Feb 2012
Posts: 9

Rep: Reputation: Disabled
Insert a new value


Hi All,

MY requirement is, whenever i find key word as "SEVERITY" it has to check the next line and if next line is not "APPLICATION" then it has to insert the value as "APPLICATION".

can someone help me how we can do this using sed/awk/perl.

My text file looks like this:

SEVERITY
APPLICATION
MESSAGE
OBJECT
....
....
SEVERITY
NODENAME
TEXT
MESSAGE
.....
.....
SEVERITY
NODENAME
TEXT
MESSAGE
........
.......
SEVERITY
TEXT
MESSAGE

......
SEVERITY
NAME
TEXT
MESSAGE

Last edited by bnbhp0; 02-24-2012 at 07:23 AM.
 
Old 02-24-2012, 07:25 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread

Tags
awk, perl, sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Insert a new value bnbhp0 Linux - General 9 02-27-2012 08:36 AM
[SOLVED] Ctrl-Insert and Shift-Insert don't work val3xiv Linux - General 2 06-30-2011 05:17 PM
insert password karlochacon Linux - Newbie 4 06-29-2010 06:58 PM
insert lines into a file after calculating where to insert xonar Programming 13 12-24-2009 04:37 AM
Insert using sed ZAMO Linux - General 6 01-15-2009 11:05 PM


All times are GMT -5. The time now is 05:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration