![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding a word in front of a word of each line. | Ramesh Vellanki | Shell Programming and Scripting | 4 | 07-02-2008 09:17 AM |
| query on how to search for a line and read 4th word from that line | jaggesh | UNIX for Dummies Questions & Answers | 4 | 07-01-2008 10:21 PM |
| to get a line above the search word | sachin.gangadha | UNIX for Dummies Questions & Answers | 16 | 01-07-2008 07:19 AM |
| how to move word by word on command line | pbsrinivas | UNIX for Dummies Questions & Answers | 1 | 11-23-2007 06:17 AM |
| Can a shell script pull the first word (or nth word) off each line of a text file? | tricky | Shell Programming and Scripting | 5 | 08-17-2006 06:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hey all,
Could any one help me ... I want to search the word and want the line above it. eg. mytxt.log My name is Jeevan. 240 is my address. My name is Jhon. 390 is my address. -------- i want to search "240" and want output as My name is Jeevan. 240 is my address. Meance i want both the line. Please suggest some solution. |
|
||||
|
Not all grep versions have the -B option. Try with awk or sed instead.
Code:
sed -n '/240/{x;p;x;p;b;};h' file
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|