Remove Specific Column in a File using awk

Hi,

I would like to ask your expertise to remove specific column no. 8 in the below file using but I don't have an idea on how to simply do this using awk command. Appreciate your help in advance.

Input f:

ABC 1 1XC
CDA 1 2YC
CCC 1 3XC
AVD 1 3XA

Expected output file:

ABC 1 1C
CDA 1 2C
CCC 1 3C
AVD 1 3A

Your sample contains only 3 columns. Also 3rd column itself it not removing completely.
Please be specific and provide correct sample data.

perl -F -ane '$F[7]=""; print @F' file
awk 'BEGIN{FS=""; OFS=""} {$8=""}'1 file

you can do this using sed,

sed -e 's/\(.......\)\(.\)\(.\)/\1\3/' inputfile.txt

Sorry, if you find my question somewhat misleading. But I refer to the position/column no. 8 to be removed in the sample data.

Column 8:

X
Y
X
X

Input file:

ABC 1 1XC
CDA 1 2YC
CCC 1 3XC
AVD 1 3XA

Output file:

ABC 1 1C
CDA 1 2C
CCC 1 3C
AVD 1 3A
1 Like

cut option..

 
cut -c 1-7,9- filename
1 Like

Thanks! This code seems to work fine...

awk '{$0=substr($0,1,8)}1' file

The above code removes the column position 9 instead of just the column position 8...

Small correction..

awk '{$0=substr($0,1,7)""substr($0,9,1)}1' file
1 Like