Sponsored Content
Top Forums Shell Programming and Scripting Remove duplicate line starting with a pattern Post 302878638 by varun22486 on Saturday 7th of December 2013 04:13:54 PM
Old 12-07-2013
Remove duplicate line starting with a pattern

HI,

I have the below input file

Code:
  /* ----------------- cmdsDlyStartFWJ -----------------*/
UNIX_JOB CMDS065J
  RUN ANY
  CMDNAME sleep 5
  AGENT CMDSHP
  USER proddata
  RUN MON,TUE,WED,THU,FRI
  DELAYSUB 02:00
  /* "Triggers daily file watcher jobs" */
  ENVAR STDOUT=/home3/cmdsprod/stdout/cmdsDlyStartFWJ
ENDJOB
 
  /* ----------------- cmdsDlyStartFWJ -----------------*/
UNIX_JOB CMDS065J
  RUN ANY
  CMDNAME sleep 5
  AGENT CMDSHP
  USER proddata
  DELAYSUB 02:00
  /* "Triggers daily file watcher jobs" */
  ENVAR STDOUT=/home3/cmdsprod/stdout/cmdsDlyStartFWJ
ENDJOB
 
  /* ----------------- cmdsDlyStartFWJ -----------------*/
 
FILE_TRIGGER CMDS065J
  RUN ANY
  CMDNAME sleep 5
  AGENT CMDSHP
  USER proddata
  RUN MON,TUE,WED,THU,FRI
  DELAYSUB 02:00
  /* "Triggers daily file watcher jobs" */
  ENVAR STDOUT=/home3/cmdsprod/stdout/cmdsDlyStartFWJ
ENDJOB

Code:
UNIX_JOB

or
Code:
FILE_TRIGGER

marks the beiginning of a job and
Code:
ENDJOB

marks the end. If you see 1st one has two entries for RUN..so what i want is to remove the RUN ANY line if there are two RUN statements

output should look like below

Code:
  /* ----------------- cmdsDlyStartFWJ -----------------*/
UNIX_JOB CMDS065J
  CMDNAME sleep 5
  AGENT CMDSHP
  USER proddata
  RUN MON,TUE,WED,THU,FRI
  DELAYSUB 02:00
  /* "Triggers daily file watcher jobs" */
  ENVAR STDOUT=/home3/cmdsprod/stdout/cmdsDlyStartFWJ
ENDJOB
 
  /* ----------------- cmdsDlyStartFWJ -----------------*/
UNIX_JOB CMDS065J
  RUN ANY
  CMDNAME sleep 5
  AGENT CMDSHP
  USER proddata
  DELAYSUB 02:00
  /* "Triggers daily file watcher jobs" */
  ENVAR STDOUT=/home3/cmdsprod/stdout/cmdsDlyStartFWJ
ENDJOB
 
  /* ----------------- cmdsDlyStartFWJ -----------------*/
FILE_TRIGGER CMDS065J
  CMDNAME sleep 5
  AGENT CMDSHP
  USER proddata
  RUN MON,TUE,WED,THU,FRI
  DELAYSUB 02:00
  /* "Triggers daily file watcher jobs" */
  ENVAR STDOUT=/home3/cmdsprod/stdout/cmdsDlyStartFWJ
ENDJOB

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove Duplicate line

Hi, I have a scenario here where I have created a flatfile with the below mentioned information. File as you can see is dispalyed in three columns 1st column is FileNameString 2nd column is Report_Name (this has spaces) 3rd column is Flag Result file needed is, removal of duplicate... (1 Reply)
Discussion started by: Student37
1 Replies

2. UNIX for Dummies Questions & Answers

modify a particular pattern starting from second line of the search pattern

Hi, I am new to this forum and i would like to get help in this issue. I have a file 1.txt as shown: apple banana orange apple grapes banana orange grapes orange .... Now i would like to search for pattern say apple or orange and then put a # at the beginning of the pattern... (2 Replies)
Discussion started by: imas
2 Replies

3. UNIX for Dummies Questions & Answers

modify a particular pattern starting from second line of the search pattern

Hi, I think you ppl did not get my question correctly, let me explain I have 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: ... (1 Reply)
Discussion started by: imas
1 Replies

4. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

5. Shell Programming and Scripting

shell script to remove all lines from a file before a line starting with pattern

hi,, i hav a file with many lines.i need to remove all lines before a line begginning with a specific pattern from the file because these lines are not required. Can u help me out with either a perl script or shell script example:- if file initially contains lines: a b c d .1.2 d e f... (2 Replies)
Discussion started by: raksha.s
2 Replies

6. Shell Programming and Scripting

How to remove all words starting from a matching word in a line

Hi Guys, I have a file like this: wwwe 1 ioie ewew yyy uuu 88 erehrlk 4 ihoiwhe lkjhassad lkhsad yyy mmm 45 jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe yyy ggg 77 I want to remove everything after "yyy" and including "yyy" from each line in the file. So I want:... (2 Replies)
Discussion started by: npatwardhan
2 Replies

7. Shell Programming and Scripting

Remove line starting from space till end.

Hi, I have a code tag, from which i have the below snippet: intelrpt.GetCMB_FB type=ODBC> intelrpt.GetCMB_FB type=SYBASE> I want the output like: intelrpt.GetCMB_FB intelrpt.GetCMB_FB That is remove the lines starting from WHITESPACE till end. Please help. I am new to... (7 Replies)
Discussion started by: anupdas
7 Replies

8. Shell Programming and Scripting

Remove duplicate occurrences of text pattern

Hi folks! I have a file which contains a 1000 lines. On each line i have multiple occurrences ( 26 to be exact ) of pattern folder#/folder#. # is depicting the line number in the file some text here folder1/folder1 some text here folder1/folder1 some text here folder1/folder1 some text... (7 Replies)
Discussion started by: martinsmith
7 Replies

9. UNIX for Beginners Questions & Answers

Grep file starting from pattern matching line

I have a file with a list of references towards the end and want to apply a grep for some string. text .... @unnumbered References @sp 1 @paragraphindent 0 2017. @strong{Chalenski, D.A.}; Wang, K.; Tatanova, Maria; Lopez, Jorge L.; Hatchell, P.; Dutta, P.; @strong{Small airgun... (1 Reply)
Discussion started by: kristinu
1 Replies

10. Shell Programming and Scripting

Remove new line starting with a numeric value and append it to the previous line

Hi, i have a file with multiple entries. After some tests with sed i managed to get the file output as follows: lsn=X-LINK-IN0,apc=661:0,state=avail,avail/links=1/1, 00,2110597,2094790,0,81,529,75649011,56435363, lsn=TM1ITP1-AM1ITP1-LS,apc=500:0,state=avail,avail/links=1/1,... (5 Replies)
Discussion started by: nms
5 Replies
RUN-MAILCAP(1)						       Run Mailcap Programs						    RUN-MAILCAP(1)

NAME
run-mailcap, view, see, edit, compose, print - execute programs via entries in the mailcap file SYNOPSIS
run-mailcap --action=ACTION [--option[=value]] [MIME-TYPE:[ENCODING:]]FILE [...] The see, edit, compose and print versions are just aliases that default to the view, edit, compose, and print actions (respectively). DESCRIPTION
run-mailcap (or any of its aliases) will use the given action to process each mime-type/file in turn. Each file is specified as its mime- type, its encoding (e.g. compression), and filename together, separated by colons. If the mime-type is omitted, an attempt to determine the type is made by trying to match the file's extension with those in the mime.types files. If the encoding is omitted, it will also be determined from the file's extensions. Currently supported encodings are gzip (.gz), bzip (.bz), bzip2 (.bz2), and compress (.Z). A file- name of "-" can be used to mean "standard input", but then a mime-type must be specified. Both the user's files (~/.mailcap; ~/.mime.types) and the system files (/etc/mailcap; /etc/mime.types) are searched in turn for informa- tion. EXAMPLES see picture.jpg print output.ps.gz compose text/html:index.htm extract-mail-attachment msg.txt | see image/tiff:gzip:- OPTIONS All options are in the form --<opt>=<value>. --action=<action> Performs the specified action on the files. Valid actions are view, cat (uses only "copiousoutput" rules and sends output to STD- OUT) , compose, composetyped, edit and print. If no action is specified, the action will be determined by how the program was called. --debug Turns on extra information to find out what is happening. --nopager Ignores any "copiousoutput" directive and sends output to STDOUT. --norun Displays the found command without actually executing it. SEE ALSO
update-mime(8) AUTHOR
run-mailcap (and its aliases) was written by Brian White <bcwhite@pobox.com>. COPYRIGHT
run-mailcap (and its aliases) is in the public domain (the only true "free"). Debian Project 1st Jan 2008 RUN-MAILCAP(1)
All times are GMT -4. The time now is 04:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy