Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another way to cut from the end of the line

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL

right now I am using too complex way:

.....|rev|cut -c1-6|rev
 
Hi

Code:
grep -o '.\{6\}$' /input/file

[gray]# or[/gray]

ruby -pe '$_=$_[-7..-1]' /input/file

[gray]# or[/gray]

sed 's/.*\(.\{6\}\)$/\1/' /input/file

[gray]# or[/gray]

awk '{print substr($0,length($0)-5)}' /input/file

[gray]# or[/gray]

gawk '{print gensub(/.*(.{6})$/,"\\1","")}' /input/file


Feherke.
 
A more portable sed way:
Code:
... | sed 's/.*\(......\)$/\1/'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top