12-18-2008
Inserting a line before the line which matches the patter
Hi
Is there any command where we can insert a line "2|||" before every line starting with "3|"
my input is as follows
1|ETG|12345
3|79.58|||GBP||
1|ETG|12345
3|79.58|||GBP||
1|ETG|12345
2|EN_GB||Electrogalvanize 0.5 m2 ( Renault )
1|ETG|12345
3|88.51|||GBP||
desired output is
1|ETG|12345
2|||
3|79.58|||GBP||
1|ETG|12345
2|||
3|79.58|||GBP||
1|ETG|12345
2|EN_GB||Electrogalvanize 0.5 m2 ( Renault )
1|ETG|12345
2|||
3|88.51|||GBP||
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I have an Input of following sort
AAAA:
ProgName="PROGRAM"
BBBB:
ProgName="BBBBBB"
CCCC:
DDDD:
ProgName="PROGRAM"
SSSS:
ProgName="PROGRAM"
ZZZZ:
ProgName="PROGRAM"
I want to find the Lines which are followed by ProgName="PROGRAM"
Out Put
AAAA: (11 Replies)
Discussion started by: pbsrinivas
11 Replies
2. Shell Programming and Scripting
I'm new to using sed and grep commands, but have found them extremely useful. However I am having a hard time figuring this one out:
Delete every line containing the word CEN and the next line as well.
ie. test.txt
blue
324 CEN
green
red
blue
324 CEN
green
red
blue
to produce:... (2 Replies)
Discussion started by: rocketman88
2 Replies
3. Shell Programming and Scripting
Friends ,
I have a large file and i need to insert a line after every line.I am actually unaware how to do it.Any help appreciated.
My File
control station *ATM* , qread $OSS.Jul13A.FI01 interval 1 intcount 1
control station *ATM* , qread $OSS.Jul13A.FI02 interval 1 intcount... (4 Replies)
Discussion started by: appu2176
4 Replies
4. Shell Programming and Scripting
I need some help. I have a file (all.txt) whereby I want to substitute using sed/awk all lines that matches an expression with another line with different expression i.e
subtitute expression,
database_id: filename;
WITH
database_id: PY;
There are many occurrences of the expression... (4 Replies)
Discussion started by: aimsoft
4 Replies
5. UNIX for Dummies Questions & Answers
I'm using sh on hp-ux and want to find / print a line that matches 132.101- and the next line, too. grep -A isn't supported on hp-ux, so I'm trying awk and sed.
The code below works but only prints the first occurence. I need all matches from the file.
awk... (2 Replies)
Discussion started by: Scottie1954
2 Replies
6. Shell Programming and Scripting
Hello All,
I have following file contents
cat file
#line=aaaaaa
#line=bbbbbb
#line=cccccc
#line=dddddd
line=eeeeee
#comment=11111
#comment=22222
#comment=33333
#comment=44444
comment=55555
Testing script
Good Luck!
I would like to comment line line=eeeeee and insert a new line... (19 Replies)
Discussion started by: manishdivs
19 Replies
7. Shell Programming and Scripting
Good day,
I have a list of regular expressions in file1. For each match in file2, print the containing line and the line after.
file1:
file2:
Output:
I can match a regex and print the line and line after
awk '{lines = $0} /Macrosiphum_rosae/ {print lines ; print lines } '
... (1 Reply)
Discussion started by: pathunkathunk
1 Replies
8. Shell Programming and Scripting
I have a file and when I match the word "initiators" in the first column I need to be able to print the rest of the columns in that row. This is fine for the most part but on occasion the "initiators" line gets wrapped to the next line. Here is a sample of the file.
caw-enabled ... (3 Replies)
Discussion started by: kieranfoley
3 Replies
9. Linux
Hi
I want to extend following command so that on the basis of "Branch: ****" on the third line I can grep and print name of the file on the first line.
cat .labellog.emd | grep DA2458A7962276A7E040E50A0DC06459 | cut -d " " -f2 | grep -v branch_name | xargs -I file <command to describe> file
... (1 Reply)
Discussion started by: ezee
1 Replies
10. Shell Programming and Scripting
Hi All,
I'm appending a line before a pattern and after another pattern(;) but omitting the first pattern - same as if comes duplicates before the second pattern.
Also, I'm adding a word before the first pattern -
Here is my file
select blah blah
hello
select blah blah
;
select... (6 Replies)
Discussion started by: Mannu2525
6 Replies
cdc(1) General Commands Manual cdc(1)
Name
cdc - change delta commentary of an SCCS file
Syntax
cdc -rSID [-m[mrlist]] [-y[comment]] files
Description
The command changes the delta commentary of each named SCCS file, for the SID specified by the -r option.
The delta commentary is defined to be the Modification Request (MR) and comment information usually specified by the command (-m and -y
options).
The commentary may consist of one or more lines, terminated by a dot in column one of a new line.
If a directory is named, behaves as though each file in the directory were specified as a named file, except non-SCCS files (last component
of the path name does not begin with s.) and unreadable files, which are silently ignored. If a name of - is given, the standard input is
read (see RESTRICTIONS). Each line of the standard input is taken to be the name of an SCCS file to be processed.
Arguments to which may appear in any order, consist of option arguments, and file names.
All the described option arguments apply independently to each named file.
Options
-m[mrlist] Adds or deletes modification numbers. If the SCCS file has the v flag set then a list of MR numbers to be added and/or
deleted in the delta commentary of the SID specified by the -r option may be supplied. For further information, see A null
MR list has no effect.
MR entries are added to the list of MRs in the same manner as that of In order to delete an MR, precede the MR number with
the character ! (see Examples). If the MR to be deleted is currently in the list of MRs, it is removed and changed into a
comment line. A list of all deleted MRs is placed in the comment section of the delta commentary and is preceded by a com-
ment line stating that they were deleted.
If -m is not used and the standard input is a terminal, the prompt MRs? is issued on the standard output before the stan-
dard input is read. If the standard input is not a terminal, no prompt is issued. The MRs? prompt always precedes the com-
ments? prompt (see -y option).
MRs in a list are separated by blanks and/or tab characters. An unescaped new-line character terminates the MR list.
Note that if the v flag has a value it is taken to be the name of a program (or shell procedure) which validates the cor-
rectness of the MR numbers. For further information, see If a nonzero exit status is returned from the MR number validation
program, terminates and the delta commentary remains unchanged.
-rSID Specifies the SCCS Identification string of a delta for which the delta commentary is to be changed.
-y[comment] Replaces existing commentary for the delta specified by the -r option. The previous comments are kept and preceded by a
comment line stating that they were changed. A null comment has no effect.
If -y is not specified and the standard input is a terminal, the prompt comments? is issued on the standard output before
the standard input is read; if the standard input is not a terminal, no prompt is issued. A dot in column one of a new line
terminates the comment text.
Certain permissions are necessary to modify the SCCS file; generally, however, if you made the delta, you can change its delta commentary,
and if you own the file and directory you can modify the delta commentary.
Examples
This example shows how to add bl78-12345 and bl79-00001 to the MR list, remove bl77-54321 from the MR list, and add the comment ``trouble''
to delta 1.6 of s.file.
sccscdc -r1.6 -m"bl78-12345 !bl77-54321 bl79-00001" -ytrouble .file
This example does the same thing.
sccscdc -r1.6 .file
-MRs? !bl77-54321 bl78-12345 bl79-00001
comments? trouble
Restrictions
If SCCS file names are supplied to the command via the standard input (- on the command line), then the -m and -y options must also be
used.
Diagnostics
See for explanations.
Files
For more information, see
For more information, see
See Also
admin(1), delta(1), get(1), help(1), prs(1), sccs(1), sccsfile(5)
Guide to the Source Code Control System
cdc(1)