Find the answer to your Linux question:
Results 1 to 3 of 3
Hello I have a variable and i want to extract the last character in a variable. How can this be done using sed (or any other way)? Thanks, mike...
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    2

    [SOLVED] How to extact the last character from a variable

    Hello

    I have a variable and i want to extract the last character in a variable. How can this be done using sed (or any other way)?

    Thanks,
    mike

  2. #2
    Just Joined! adrianx's Avatar
    Join Date
    Feb 2008
    Posts
    27
    Quote Originally Posted by mike45 View Post
    Hello

    I have a variable and i want to extract the last character in a variable. How can this be done using sed (or any other way)?

    Thanks,
    mike
    You could try e.g.:
    Code:
    ${YOURVAR:(-1)}

  3. #3
    Just Joined!
    Join Date
    Apr 2009
    Posts
    2

    thx

    thx - that did it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...