![]() |
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 |
| Using grep to extract line number | mskarica | Shell Programming and Scripting | 8 | 06-26-2008 02:47 AM |
| Adding a columnfrom a specifit line number to a specific line number | Ezy | Shell Programming and Scripting | 2 | 05-12-2008 08:29 AM |
| Extract a line from a file using the line number | zambo | Shell Programming and Scripting | 1 | 05-01-2008 01:39 PM |
| Appending the line number and a seperator to each line of a file ? | pjcwhite | Shell Programming and Scripting | 4 | 03-21-2007 01:29 AM |
| Get line form file by line number | corny | Shell Programming and Scripting | 3 | 08-25-2006 12:18 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
extract a line from a file using the line number
Hello,
I am having trouble extracting a specific line from a file when the line number is known. My first attempt involved grep -n 'hi' (the word 'hi will always be there) to get the line number before the line that I actually want (line 4). Extra Notes: -I am working in a bash script. -The file size is always variable, so I couldn't use head or tail. #file that I am evaluating Code:
hello hey hi there <-line that i want how are you doing |
|
||||
|
Quote:
head -4 | awk '{ print $1 }' < filename | tail -1 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|