remove white space from specific columns in text file

Hello

i have a text file like this:

1 AB AC AD EE
2 WE TR YT WW
3 AS UY RF YT

the file is bigger , but that's an example of the data

what i want to do is to merge all columns together except the first one,
it will become like this :

1 ABACADEE
2 WETRYTWW
3 ASUYRFYT

how this can be done ??

thanks in advance

use this sed script (assuming there is no : in the data)

 
s/ /:/
s/ //g
s/:/ /

hello , thanks for your reply , but it did not worked

Another way:

awk '{s=$1;gsub($1 FS,x);$1=$1;print s FS $0}' OFS= file
1 Like

thanks a lot Franlin52 it worked

An infile replacement:

# cat file
1 AB AC AD EE
2 WE TR YT WW
3 AS UY RF YT
# perl -ni -e '($a,$b)=/^(\S+\s)(.*)/;$b=~s/\s//g;print $a.$b."\n";' file
# cat file                                                               
1 ABACADEE
2 WETRYTWW
3 ASUYRFYT
1 Like

i have another question concerning this data set , should i ask it here ? or open another thread??

I should open a new thread for a new question.

One more way

sed 's/ //g;s/^\([[:digit:]]*\)/\1 /g' infile

regards,
Ahamed