Categories
Linux Mastering Development

How to remove column from file without altering format?

I need to remove the first column from files like this:

   165  1   chr22   42090593    0   1   chr22   42090609    1   42  42
    166 1   chr22   42090593    0   1   chr22   42090654    1   42  42
    167 1   chr22   42090595    0   1   chr22   42090633    1   42  42
    168 0   chr22   42090612    0   1   chr22   42090656    1   42  42
    169 0   chr22   42090614    0   0   chr22   42090617    1   40  42
    170 0   chr22   42090647    0   1   chr22   42090749    1   42  42
    171 1   chr22   42090684    0   1   chr22   42090692    1   42  42
    172 1   chr22   42090733    0   1   chr22   42090743    1   42  42
    173 1   chr22   42090733    0   1   chr22   42090775    1   42  42
    174 1   chr22   42090733    0   1   chr22   42090789    1   42  42
    175 1   chr22   42090757    0   1   chr22   42090787    1   42  24
    176 0   chr22   42090778    0   0   chr22   42090790    1   42  42
    177 0   chr22   42090800    0   0   chr22   42090802    1   42  42
    178 0   chr22   42090803    0   0   chr22   42090806    1   42  42

The command

awk '{$1=""; print $0}'

correctly remove the first column but alters the format this way

 1 chr22 51178322 0 0 chr22 51178659 1 42 42
 0 chr22 51178661 0 0 chr22 51178663 1 42 42
 0 chr22 51178667 0 1 chr22 51178790 1 42 23
 1 chr22 51178755 0 0 chr22 51178764 1 42 42
 0 chr22 51178808 0 1 chr22 51178871 1 42 42
 1 chr22 51178869 0 1 chr22 51178895 1 42 42
 1 chr22 51178881 0 1 chr22 51178893 1 42 42
 1 chr22 51178881 0 1 chr22 51178895 1 42 42
 1 chr22 51179213 0 1 chr22 51179213 1 42 42
 1 chr22 51180087 0 1 chr22 51180093 1 42 42
 1 chr22 51180134 0 0 chr22 51181889 1 42 42
 0 chr22 51186192 0 0 chr22 51186192 1 42 42
 0 chr22 51186192 0 0 chr22 51186192 1 42 42

Any idea?

Leave a Reply

Your email address will not be published. Required fields are marked *