![]() |
|
|
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 |
| extract a field by logic | ChicagoBlues | UNIX for Dummies Questions & Answers | 4 | 01-27-2009 02:00 PM |
| need to extract field of characters in a line | jansat | Shell Programming and Scripting | 3 | 05-22-2008 10:44 AM |
| How to extract field from variable more efective | pp56825 | Shell Programming and Scripting | 11 | 01-19-2008 10:34 AM |
| Extract Part of string from 3rd field $3 using AWK | stakuri | Shell Programming and Scripting | 4 | 10-10-2007 01:28 PM |
| Trying to extract a field from /etc/passwd file.. | xBuRnTx | UNIX for Dummies Questions & Answers | 2 | 10-05-2005 03:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to extract last occurence of the field
path = /first/second/third/fourth. i want to extract /first/second/third from path.my program something like this ....
path=/first/second/third/fourth noc=`echo $path|tr '/' '\n'|wc -w` var='echo $noc|cut -d'/' -f 1-$noc --> is giving error. why $noc is not working here.any other alternative to extract it. Thanks kcp_pavan |
|
||||
|
reply
both soultions worked effectively. thanks to Goldorakk and radoulov .......
one more sol : ------------------ path=/first/second/third/fourth echo $path | nawk '{print $NF}' FS="/" | read FILE echo "File Name: "$FILE --> fourth echo ${path%/*} | read PAT echo "Path: "$PAT --> /first/second/third |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|