3

I have a text file like this

abcdefg
abcdefg
abcdefg
abcdefg

How to delete the first and last two characters from each line with sed? I would like to get the output like this

bcde
bcde
bcde
bcde
mtk
  • 13,221
  • 16
  • 72
  • 112
Joel
  • 67
  • 1
  • 1
  • 5

2 Answers2

4
sed  's/^.\(.*\)..$/\1/'  file

codaddict
  • 445,704
  • 82
  • 492
  • 529
0

This might work for you:

sed 's/^.\|..$//g' file
potong
  • 55,640
  • 6
  • 51
  • 83