Search for Pattern and Print including Lines in between


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search for Pattern and Print including Lines in between
# 8  
Old 10-05-2010
Still want to sort it?
# 9  
Old 10-05-2010
Quote:
Originally Posted by The One
what if i dont want the "Updated" included? like it will only print lines from "Name" until before "Updared"?
Code:
awk '/Update/{f=0}/Name/{f=1}f' file

# 10  
Old 10-05-2010
when i ran danmero code, i got from line Name to before updated :
Code:
awk '$1=="Updated:"{f=0}$1=="Name:"{f=1}f' file

is that what you wanted?
# 11  
Old 10-05-2010
Quote:
Originally Posted by DGPickett
Still want to sort it?
i just want to get an output of:

Code:
Name: xxxx yyyy nnnn
Description: dfffgs  sdgsgsf hsfhhs
afgghhjdgj
fjklllll   gsfhfh

without the "Updated" line.

---------- Post updated at 09:44 AM ---------- Previous update was at 09:35 AM ----------

Quote:
Originally Posted by dragon.1431
when i ran danmero code, i got from line Name to before updated :
Code:
awk '$1=="Updated:"{f=0}$1=="Name:"{f=1}f' file

is that what you wanted?
i've got syntax error "bailing out near line 1"

---------- Post updated at 09:44 AM ---------- Previous update was at 09:44 AM ----------

Quote:
Originally Posted by Franklin52
Code:
awk '/Update/{f=0}/Name/{f=1}f' file

i've got syntax error "bailing out near line 1"
# 12  
Old 10-05-2010
hi,
as per this you might be using old one for awk.
please try using nawk instead of awk.
# 13  
Old 10-05-2010
sed -n '
/Name/,/Updated/{
/Updated/!p
}
' file
# 14  
Old 10-05-2010
the nawk works! thanks Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

2. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

3. Shell Programming and Scripting

Search Pattern and Print lines in Single Column

Hi Experts I have small query where I request the into a single file Suppose: File1: {Unique entries} AA BB CC DD FileB: AA, 123 AA, 234 AA, 2345 CC, 123 CC, 5678 DD,123 BB, 7890 (5 Replies)
Discussion started by: navkanwal
5 Replies

4. Shell Programming and Scripting

Search pattern on logfile and search for day/dates and skip duplicate lines if any

Hi, I've written a script to search for an Oracle ORA- error on a log file, print that line and the .trc file associated with it as well as the dateline of when I assumed the error occured. In most it is the first dateline previous to the error. Unfortunately, this is not a fool proof script.... (2 Replies)
Discussion started by: newbie_01
2 Replies

5. Shell Programming and Scripting

Including EOL in egrep pattern for multiple lines

Hi all I need your help to get a high-performance solution. I am working on a extensive script to automate file restores using the bprestore tool on a Solaris 5.10 server (bash 3.00). I will only paste the needed parts of the script to avoid any confusion. To use the script the user has to... (2 Replies)
Discussion started by: Anonym
2 Replies

6. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

7. Shell Programming and Scripting

Print a pattern between the xml tags based on a search pattern

Hi all, I am trying to extract the values ( text between the xml tags) based on the Order Number. here is the sample input <?xml version="1.0" encoding="UTF-8"?> <NJCustomer> <Header> <MessageIdentifier>Y504173382</MessageIdentifier> ... (13 Replies)
Discussion started by: oky
13 Replies

8. Shell Programming and Scripting

Search for a pattern in a file and print previous lines from a particular point

Hi, I am new to ksh scripting and I have a problem. I have a file in which I have to search for a particular pattern say 'a' then from that line I need to search for another pattern say 'b' in the previous lines and thne print the file from pattern 'b' till the end of file. For eg: ... (2 Replies)
Discussion started by: umaislearning
2 Replies

9. UNIX for Dummies Questions & Answers

Print lines between the search pattern

hi, I have a file say x.txt containing xxx 123 bla bla ... you xxx dfk dbf ... me xxx ... ... keeps on.. i need to search for pattern in the line starting xxx in the file. If pattern matched, I need to fetch all the lines till i find next xxx. (17 Replies)
Discussion started by: prsshini
17 Replies
Login or Register to Ask a Question