Learning the grep command and came across this. How does it work combined with tail? [duplicate]

What wouldgrep '&' input.txt | tail -4 give me? I am new to this and cannot figure out what happens using grep and tail together.

2

1 Answer

tail -4 when executed with a file would normally print the last four lines of the file

With:

grep '&' input.txt | tail -4

The tail command is being executed on the output of the grep command and so will print the last 4 lines of the output of grep.

If for example there are 50 occurrences of "&" in input.txt, only the last 4 will print.

You Might Also Like