Hi all,
Please help me to remove first and last character of each line in a file.
Thanks,
Baski
Hi all,
Please help me to remove first and last character of each line in a file.
Thanks,
Baski
sed 's/.\(.\+\).$/\1/'
one more ..
$ sed 's,^.,,g;s,.$,,g' infile
Yet another one:
sed 's/.\(.*\)./\1/' file
Hi,
I think all previous solutions remove a leading and trailing blank space if exist. If you want to omit them, try next perl command. One example:
$ cat infile
monday
tuesday
wednesday
thursday
friday
$ cat -A infile
monday$
tuesday$
wednesday $
^Ithursday^I$
friday$
$ sed 's/.\(.\+\).$/\1/' infile
onda
tuesda
ednesday
thursday
rida
$ sed 's,^.,,g;s,.$,,g' infile
onda
tuesda
ednesday
thursday
rida
$ sed 's/.\(.*\)./\1/' infile
onda
tuesda
ednesday
thursday
rida
$ perl -lpe 's/\S//; s/\S(\s*)$//' infile
onda
uesda
ednesda
hursda
rida
Regards,
Birei
# sed '
/^[ \t]/s/^\([ \s]\+\).\(.*\)./\1\2/
/^[^ ]\(.\).*/s/^.\(.*\).$/\1/
/[ \t]$/s/\([^ ]\)[^\S][ \t]*$/\1/' infile
regards
ygemici