![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| reading from two files line by line | windows | Shell Programming and Scripting | 2 | 08-09-2008 03:58 AM |
| reading ps command's output line by line | s. murat | Shell Programming and Scripting | 5 | 05-22-2008 01:23 AM |
| reading text file line by line | MizzGail | Shell Programming and Scripting | 6 | 04-14-2008 03:58 AM |
| reading line by line and grepping | QueryMaster | Shell Programming and Scripting | 4 | 01-30-2008 02:12 PM |
| Reading line by line from a file | tej.buch | Shell Programming and Scripting | 2 | 01-22-2006 11:50 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
reading in the last line from grep
hi all,
from a shell (ksh) script, i am doing a grep which returns multiple lines. how do i read the last line returned into a variable ?? ta. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
grep <pattern> <source> | tail -1
|
|
#3
|
|||
|
|||
|
hey thanks, how do i reuse the grep command output which i stored in a variable to get the last line ?? e.g
#!/bin/ksh . . . myVar=$(grep "errorPort" systemlog.log); myLastLine=$($myVar | tail -1); this doesnt seem to work. any suggestions ?? |
|
#4
|
||||
|
||||
|
try it in this way
echo "$myvar"|tail -1 |
|
#5
|
|||
|
|||
|
Code:
myVar=$(grep "errorPort" systemlog.log | tail -1); |
|
#6
|
|||
|
|||
|
tail -1
|
|||
| Google The UNIX and Linux Forums |