I am looking for one liner, I hope that can trim the first and last character of a line, on multiple lines, for example. test.txt
Before:
xyyyyyyyyyyyyyyyyyyyx pyyyyyyyyyyyyyyyyyyyz
After:
yyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyy
$ cat /tmp/txt xyyyyyyyyyyyyyyyyyyyx pyyyyyyyyyyyyyyyyyyyz $ sed 's/^.\(.*\).$/\1/' /tmp/txt yyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyy
sed -ne 's,^.\(.*\).$,\1,p'
This command will delete all lines with less than two characters, since you cannot delete the first and last characters from them.
There is a little trick :)
sed 's / ^. (. *). $ / \ 1 / 'file> file1; rm file; echo file1> file; rm file1