![]() |
|
|
|
|
|||||||
| 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 |
| select a record from one file matching from second file using awk | synmag | Shell Programming and Scripting | 7 | 06-11-2008 11:37 PM |
| select a portion of a file into a CSV | anju | Shell Programming and Scripting | 8 | 02-27-2008 10:50 PM |
| Select last block from a file | misenkiser | Shell Programming and Scripting | 9 | 10-11-2006 06:32 AM |
| select distinct row from a file | merry susana | UNIX for Dummies Questions & Answers | 7 | 05-03-2005 03:54 AM |
| select datas from an input file | dde | Shell Programming and Scripting | 1 | 05-21-2002 08:02 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
select last field from a file
hi everybody
i would to select the last field of a file here as you can see i select the field number 8 y=`cat sortie2 | grep "^[1-9999]"| grep "starting"| awk '{ print $8}'` but line can containt more or less field in never know, i just know is the last one so i wondering to know if is something like y=`cat sortie2 | grep "^[1-9999]"| grep "starting"| awk '{ print $lastfield}'` or a other solution thank a lot |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
y=`cat sortie2 | grep "^[1-9999]"| grep "starting"| awk '{ print $NF}'
|
|
#3
|
||||
|
||||
|
I'm not sure that the command "grep" is doing what you want.
This command selects lines starting with a digit (from 1 to 9). If you want to select lines with field 1 between 1 and 9999, you can do: Code:
y=`awk '$1 > 1 && $1 <9999 && /starting/ { print $NF }' sortie2`
|
|
#4
|
|||
|
|||
|
thank a lot that works
|
|||
| Google The UNIX and Linux Forums |