![]() |
|
|
|
|
|||||||
| 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 |
| count times for one string | anhtt | Shell Programming and Scripting | 1 | 03-04-2008 10:46 AM |
| count string occurance in a file hourly | ayhanne | UNIX for Dummies Questions & Answers | 2 | 10-13-2007 07:47 AM |
| Count string at header. | Helmi | Shell Programming and Scripting | 13 | 04-25-2007 04:16 AM |
| How to count the string length | Anshu | UNIX for Dummies Questions & Answers | 2 | 06-15-2006 12:32 AM |
| Word Count without any characters but the Output String | JP_II | UNIX for Dummies Questions & Answers | 3 | 06-07-2006 05:19 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
count from right end of string
hi all,
I'm trying to use substr(p,c,l) in awk but i'd like to have the 'position' argument count from the right end of the string instead of left end. evidently, just putting a '-' sign in front of the number does not work. any ideas? cheers, kl |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Try something like
nawk '{print(substr($0,length($0)-4,1))}' myfile Which'll print the fifth character from the right hand side of each record (assume position is zero-indexed). Cheers ZB |
||||
| Google The UNIX and Linux Forums |