Sed to remove first or last character in a string.
- July 1st, 2009
- Posted in Documentation
- Write comment
To remove the first character in a string:
echo $STRING |sed โs/.\(.*\)/\1/โ
To remove the last character in a string:
echo $STRING | sed โs/\(.*\)./\1/โ
To remove the last five characters in a string:
echo $STRING | sed โs/\(.*\)โฆ../\1/โ
To remove all whitespace at the end of the line:
echo $STRING | sed โs/[ ]*$//โ
No comments yet.