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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed string manipulation

Status
Not open for further replies.

bourgui

MIS
Sep 10, 2002
6
0
0
BE
Hi all,

I've this as value in a string : ABCDEFGH and I'd like to cut it by keeping only the last character 'H'. Keep in mind the value in the string could be less or more characters as in the example.

Can you tell me if it's possible to do it with a sed command ?

Thx in advance,
J-L.
 
Something like this ?
string="ABCDEFGH"
LastChar=`echo "$string" | sed 's!.*\(.\)!\1!'`

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

That's exaclty what I wanted. Thx for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top