![]() |
|
|
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 |
| Help in extracting data with command from file in C | ahjiefreak | High Level Programming | 10 | 03-20-2008 11:26 PM |
| Extracting specific info from finger command | franny | UNIX for Dummies Questions & Answers | 1 | 12-05-2007 01:13 PM |
| Extracting only file size of the ls -ltr command. | kingofprussia | UNIX for Dummies Questions & Answers | 6 | 12-03-2007 03:14 AM |
| sed substitute / for \ : error "Function can not be parsed" | candyflip2000 | Shell Programming and Scripting | 3 | 07-18-2006 04:02 AM |
| Extracting one column from a ps -ef command | m223464 | Shell Programming and Scripting | 6 | 04-03-2005 12:36 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Extracting last parsed segment with the cut command
I can see in the man pages how cut can be used to extract a specified string by using the -f qualifier. However, I can't find anywhere how to specify the "last" parsed segment with the cut command. If the string you are parsing is (or can be) differant each time the script is run, but you know that you always want the last segment parsed from the input string, how do you so specify in your command?
THanks Phudgens Denver |
|
||||
|
instead of cut, you could use awk:
Code:
echo "one two three four" | awk '{print $NF}'
Code:
echo "one two three" | awk '{print $NF}'
The variable 'NF' by itself is the number of fields in the record (line), and if you prefix that with a '$' then that will give you the last field. hth |
|
||||
|
Quote:
Code:
set CurrentFolder = ${PWD##*/}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|