8

File1

Sergio
Lionel
Luis
Andreas
Gerard

I want my stdout to have just

Sergio
Gerard

How can I do this using the tail command and piping?

Kylo Ren
  • 115
  • 1
  • 1
  • 2

2 Answers2

18

This should do the trick:

$ head -n 1 File1; tail -n 1 File1
vespid
  • 339
  • 2
  • 9
10

With sed:

sed -n -e '1p;$p' File1
cas
  • 1
  • 7
  • 119
  • 185