I have a very large colon-delimited file with two columns:
dhsj fdksjdk:dndkdlkfkd shfdosod dkjsosjd:dkj dosjeod dhswisoaidodisbw: dhsoi wjdos fjfdododjfideefkjso sn:fhfdkd dkdjdf
If the first column contains a space, I need to remove it (i.e. collapse text together):
dhsjfdksjdk:dndkdlkfkd shfdosoddkjsosjd:dkj dosjeod dhswisoaidodisbw: dhsoi wjdos fjfdododjfideefkjsosn:fhfdkd dkdjdf
In other words, everything to the left of the colon needs to be stripped of spaces, and everything to the right of the colon needs to remain untouched.
I know how to use
cut -d ":" f1 to pull the first column and
tr -d '[[:blank:]]' to filter out space or tab characters, but then I would have to place that column back into the file and this seems like a roundabout way of doing things.
What's the most efficient way to do what I want here?