![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| ksh Checking if variable has 5 digits | developncode | UNIX for Dummies Questions & Answers | 3 | 04-08-2008 03:57 PM |
| Digits display | Spoorthi16 | UNIX for Dummies Questions & Answers | 3 | 10-01-2007 08:26 PM |
| Grep a line with between 3 and 5 digits | ceemh3 | UNIX for Dummies Questions & Answers | 1 | 09-17-2007 03:24 PM |
| Only Digits as input | namishtiwari | UNIX for Dummies Questions & Answers | 2 | 08-21-2007 06:23 AM |
| restrain the number of digits of a PID | mlefebvr | UNIX for Advanced & Expert Users | 1 | 05-27-2002 09:33 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to cut last 10 digits off
Hi I'm new to this. I need to cut off the last 10 digits from a line.
I've used awk {'print $4'} filename.txt | cut -c 32-42 but this does not guarantee only the last 10 characters. Please help. Thanks. Sara |
|
||||
|
Quote:
If you are using BASH as shell. This would work. Code:
while read line; do echo ${line:(-10)}; done < filename
Code:
awk '{LEN=length($0);print substr($0,LEN-9)}' filename
Last edited by vish_indian; 08-28-2006 at 08:17 AM.. Reason: Added awk based solution |
|
||||
|
Thanks guys. They all work. You guys are really good.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|