Reputation: 129
I am looking for I one liner hopefully, that can trim the first and last character of a line, on multiple lines e.g. test.txt
Before:
xyyyyyyyyyyyyyyyyyyyx
pyyyyyyyyyyyyyyyyyyyz
After:
yyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyy
Upvotes: 5
Views: 12367
Reputation: 11
There is little trick :)
sed 's/^.(.*).$/\1/' file > file1 ; rm file ; echo file1 > file ; rm file1
Upvotes: 1
Reputation: 41625
sed -ne 's,^.\(.*\).$,\1,p'
This command will delete all lines that have less than two characters, since one cannot really strip the first and last character from them.
Upvotes: 0
Reputation: 3268
$ cat /tmp/txt
xyyyyyyyyyyyyyyyyyyyx
pyyyyyyyyyyyyyyyyyyyz
$ sed 's/^.\(.*\).$/\1/' /tmp/txt
yyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyy
Upvotes: 14