Skip to content
Advertisement

Bash sort ignore first 5 lines

I’m having trouble ignoring the first 5 lines of my file while sorting the rest. My current command sorts the entire file by the second item, however I need to skip the first 5 “header” lines. I need read it and write it to the same file.

Current Command

JavaScript

Example

JavaScript

Advertisement

Answer

This sorts lines 6 and after of the file while leaving the first 5 lines unchanged:

JavaScript

tcsh

Unlike bash, ksh, and zsh, tcsh does not support command grouping with {...}. Instead try a subshell:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement