Removing columns in text file with Bash? Removing columns in text file with Bash? unix unix

Removing columns in text file with Bash?


This might work for you:

finger |  sed 's/\(.\{35\}\)...../\1/'

or this:

finger |  cut --complement -c36-40 


This solution is not perfect: the column position and width might change. If they are constant, the following command will do the trick by removing text columns 34 to 39 inclusively:

finger | colrm 34 39


If "\t" is used as column delimiter then you can get rid of 4th column using awk and delete doubled "\t" using sed. For example:

finger | awk -F"\t" -v 'OFS=\t' '{ $4=""; print $0}' | sed 's/\t\{2,\}/\t/'