Remove extra header lines from file, except for the first line
You can use
sed '2,${/ID/d;}'
This will delete lines with ID starting from line 2.
header=$(head -n 1 input)
(printf "%s\n" "$header";
grep -vFxe "$header" input
) > output
- grab the header line from the input file into a variable
- print the header
- process the file with
grep
to omit lines that match the header - capture the output from the above two steps into the output file
For those who do not like curly brackets
sed -e '1n' -e '/^ID/d'
n
meanspass
line No.1
d
delete all matched line(s) that start with^ID