03-29-2009
SED/ AWK to do selective insert
I would appreciate if any one could give a handy one-liner in sed/awk to insert a line between two lines if and only if a condition is NOT fulfilled
sample input record:
*field* 1
*field* 2
*field* 3
*field* 1
*field* 3
sample output record:
*field* 1
*field* 2
*field* 3
*field* 1
*field* 2
*field* 3
insert word between two lines if word does not occur
else
leave as is.
I know to do this in perl, but I am just looking for an awk/sed command that would accomplish the same.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
How can i use insert and change command in ksh shell.
I am using :
sed -e '1i\TEXTTOBEINSERTED\' FILENAME
But there is no effect...
Also
sed -e 'c\thisischange\' Filename
Please Explain how to proceed?? (2 Replies)
Discussion started by: JunkYardWars
2 Replies
2. Shell Programming and Scripting
I'm attempting to insert multiple lines before a line matching a given search pattern. These lines are generated in a separate function and can either be piped in as stdout or read from a temporary file.
I've been able to insert the lines from a file after the pattern using:
sed -i '/pattern/... (2 Replies)
Discussion started by: zksailor534
2 Replies
3. Shell Programming and Scripting
I have done this sed command to insert one line after a specific string is found:
sed '/patternstring/ a\
new line string' file1
But how do I insert two lines? This is not possible:
sed '/patternstring/ a\
new line string \a
new line string 2' file1 (2 Replies)
Discussion started by: locoroco
2 Replies
4. Shell Programming and Scripting
Greetings all,
I am trying to match a string, and after that insert a few lines above that match.
The string is "Version 1.0.0". I need to insert a few lines ONLY above the first match (there are many Version numbers in the file). The rest of the matches must be ignored. The lines I need to... (2 Replies)
Discussion started by: nagaraj s
2 Replies
5. Shell Programming and Scripting
Hi
I am trying to insert a block of text 2 lines above a pattern match using sed
eg
#Start of file entry
{
}
#End of file entry
new bit of text has to be put in just above the } eg
#Start of file entry
{
New bit of text
}
#End of file entry (7 Replies)
Discussion started by: eeisken
7 Replies
6. UNIX for Dummies Questions & Answers
Hello all. I am a beginner UNIX user who is using UNIX to work on a bioinformatics project for my university.
I have a bit of a complicated issue in trying to use sed (or awk) to "find and replace" bases (letters) in a genetics data spreadsheet (converted to a text file, can be either... (3 Replies)
Discussion started by: Mince
3 Replies
7. Shell Programming and Scripting
Hi,
I have a problem where I need to make this input:
nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a
nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b
look like this output:
nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Discussion started by: nricardo
4 Replies
8. UNIX for Dummies Questions & Answers
By using sed command, How to insert a new line before the last four lines of the file.
Old Line
Old Line
NEW LINE!
Old Line
Old Line
Old Line
Old Line (8 Replies)
Discussion started by: wridler
8 Replies
9. Shell Programming and Scripting
Hi!
Considering below text, how would I use sed to insert text right below the v0005-line, using the SEPARATOR-line as a pattern to search for, so two lines above the separator? I can do it right above the separator, but not 2 lines...
# v0004 - Some text
# v0005 - More text
#... (5 Replies)
Discussion started by: indo1144
5 Replies
10. Shell Programming and Scripting
Hello, I am trying to insert a section of text between lines in another text file.
The new lines to be inserted are:
abcd.efgh.zzzz=blah
abcd.efgh.xxxx=blah
Where N = 0 to 2
Original File:
abcd.efgh.wwxx=aaaaa
abcd.efgh.yyzz=bbbbb
abcd.efgh.wwxx=aaaaa
abcd.efgh.yyzz=bbbbb... (3 Replies)
Discussion started by: tsu3000
3 Replies
LEARN ABOUT DEBIAN
px_put_data_bcd
PX_PUT_DATA_BCD(3) Library Functions Manual PX_PUT_DATA_BCD(3)
NAME
PX_put_data_bcd -- Put value into a bcd data field
SYNOPSIS
#include <paradox.h>
void PX_put_data_bcd(pxdoc_t *pxdoc, char *data, int len, char *value)
DESCRIPTION
Converts a bcd string into a value for a data field as it stored in the database file. The string may only contain the charcters `+', `-',
`0-9', and `.'. You should use this function instead of accessing the record data directly.
data points to the start of the data field in the record. It must be calculated by summing up all field length before the field to operate
on and add it to the base pointer of the record.
SEE ALSO
PX_put_data_alpha(3), PX_put_data_long(3), PX_put_data_double(3), PX_put_data_short(3), PX_put_data_byte(3), PX_put_data_bytes(3)
AUTHOR
This manual page was written by Uwe Steinmann uwe@steinmann.cx.
PX_PUT_DATA_BCD(3)