![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 07:24 AM |
| Multiple file processing - 1st line only to process - search/match substring | toneatlondon | Shell Programming and Scripting | 2 | 01-02-2008 06:20 PM |
| Search first line of compressed file | cbreiner | UNIX for Advanced & Expert Users | 1 | 09-05-2007 02:52 PM |
| search and retrieve previous line in file | paulsew | Shell Programming and Scripting | 2 | 02-23-2007 05:04 AM |
| In Line File Modifications: Search and Replace | Shakey21 | Shell Programming and Scripting | 2 | 11-20-2001 01:21 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Search in a file and get the next line as well
Hi All,
i'm new here in the forum and UNIX too. I have a quick question. I have a file containing the following lines: 3:40:27 su :0002:9999:2:399 [ID 366847 auth.info] 'su sdfrun' succeeded for root on /dev/??? 23:40:29 su :0005:0342:2:1 Disk Utilization threshold What i want to do is search for a parameter on the first line e.g. 0005 and have as result time and second line printed as well. This is my expected printout if I search for 0005 23:40:29 su :0005:0342:2:1 Disk Utilization threshold So far i did this, but it doesn't help "#!/bin/ksh for enum in "0005 0060 0055" do while IFS= read -r line do echo "grep $enum /home/salvatore/alarms/$IFS" done < input_file This gives me just the first line Thanks a lot |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
sed -n '/0005/{N;p;}' input_file
|
|
#3
|
|||
|
|||
|
Thanks a lot
|
|||
| Google The UNIX and Linux Forums |