-1

enter image description here

Your help will be really appreciated

jww
  • 97,681
  • 90
  • 411
  • 885
Bipin
  • 31
  • 5
  • 1
    Do you just have an empty new line at the end of `cars`? – Kevin Mar 04 '18 at 06:24
  • 1
    The last line in file is empty and tail is showing that. – codeforester Mar 04 '18 at 06:24
  • Welcome to Stack Overflow! SO is for programming questions, not questions about using or configuring Linux and its applications. SuperUser.com or unix.stackexchange.com would be better places for questions like this. – Barmar Mar 04 '18 at 06:25
  • I don't have any empty line at the end of cars.@Kevin – Bipin Mar 04 '18 at 06:42
  • Please state the output and the errors. The text on the picture cannot be indexed by search engines for future visitors. – jww Mar 04 '18 at 10:41

2 Answers2

1

Your cars files ends with a blank line, as can be seen when you cat it. Thus, tail -3 cars prints the last three lines in the file: Cadillac, Ford and an empty line.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • I placed the cursor right after the Ford and tried the tail command but still showing the same output. – Bipin Mar 04 '18 at 06:31
-1

As the others said, you need to delete the empty line. Open the file, place the cursor below Ford and hit backspace, save the file and try again.

J.Doe
  • 17
  • 6
  • That last ‘return’ is pretty significant. Maybe give everyone some credit by tapping their up triangles. – J.Doe Mar 04 '18 at 06:56
  • Hi @J.Doe can you explain this to me ? $ cat cars Ferrari Porsche Merc BMW Honda Toyota Nissan $ tail -3 cars Honda Toyota Nissan $ tail +3 cars Merc BMW Honda Toyota Nissan Why is it showing a different output in tail +3 cars? – Bipin Mar 04 '18 at 06:57
  • Type ‘man cat’ and see what that says. Try ‘man tail’ – J.Doe Mar 04 '18 at 07:01
  • My implementation may be a little different than yours, it does not like ‘tail +3 cars’ it wants ‘tail -n +3 cars’ ... but in that case it is starting at the third item and proceeding to the end, as you obtained. Give a little credit to those that have helped you. – J.Doe Mar 04 '18 at 07:24
  • Yeah, bipin, I really appreciate that – J.Doe Mar 04 '18 at 13:20