Showing posts with label sed. Show all posts
Showing posts with label sed. Show all posts

Friday, November 6, 2009

How to delete the last character in a line?

This is simple and without any description, here is the regex.


# echo "This is last character" | sed 's/.$//g'
This is last characte

Thursday, June 19, 2008

SED & TR uses

Here are the quickies for my very own sed and tr:

To replace "NEWLINE" (\n) with "comma" (,)
cat filename | tr '\n' ','


To find "tree" and replace with "plant" in a file (using sed):
sed -i 's/tree/plant/g' filename