Quote:
|
Originally Posted by psarava
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
|
If you are using BASH as shell. This would work.
Code:
while read line; do echo ${line:(-10)}; done < filename
Another way using awk(gawk)
Code:
awk '{LEN=length($0);print substr($0,LEN-9)}' filename
Last edited by vish_indian; 08-28-2006 at 09:17 AM..
Reason: Added awk based solution
|