Take the 2-minute tour ×

I´d like to compare two files, but I don´t want to take into account the first 10 lines, and the last 3 lines of both files. I tried to do it with diff and tail commands, like in here, but without success. how can I do it?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Use GNU tail and head:

To ignore the first 10 lines of a file, use tail like this:

tail -n +11 file

To ignore the last 3 lines of a file, use head like this:

head -n -4 file

You can then construct your diff command using process substitution as follows:

diff <(tail -n +11 file | head -n -4) <(tail -n +11 file2 | head -n -4)
share|improve this answer
add comment

Your Answer


