I have a space delimited input text file. I would like to delete columns where the column header is size using sed or awk.
Input File:
id quantity colour
If you have GNU cut available this can be done like so:
columns=$(head -n1 INPUT_FILE \
| tr ' ' '\n' \
| cat -n \
| grep size \
| tr -s ' ' \
| cut -f1 \
| tr -d ' ' \
| paste -sd ",")
cut --complement -d' ' -f$columns INPUT_FILE
Which generates a comma separated list based on the heading, and then cuts the complement of that list from INPUT_FILE.