Reputation: 5141
I'm having some problem with paste command in bash
I have a bunch of three comma separated column text files that share columns 2 and 3. First I create a txt file by extracting this shared columns from a single data file
awk 'BEGIN { FS = "," }{ print $2 "," $3}' file01.txt > msg-coord.txt
Then I run through a loop to get the first column of each file in the list
for hora
in 00 01 02 03
do
awk 'BEGIN { FS = "," }{ print $1 }' file$hora.txt > a$hora.txt
done
then try to paste all new files (runs fine)
paste -d "," a{00..03}.txt > temporal.txt
and add the msg-coord.txt through paste command, this is not working and I can't find out why
paste -d "," msg-coord.txt temporal.txt > msgdata.txt
Output of head msgdata.txt
yields
,-0.0127,-0.1773,-0.3749,-0.3780
,-0.0318,-0.1941,-0.3780,-0.3877
,-0.0510,-0.2109,-0.3807,-0.3973
,-0.0703,-0.2277,-0.3833,-0.4068
,-0.0900,-0.2450,-0.3864,-0.4168
,-0.1101,-0.2632,-0.3903,-0.4272
where the two columns from msg-coord.txt are missing.
fileXX.txt look like
-0.3686,-12.5000,33.5000
-0.3877,-12.5000,33.5800
-0.3973,-12.5000,33.6200
-0.4068,-12.5000,33.6600
-0.4168,-12.5000,33.7000
-0.4272,-12.5000,33.7400
-0.4382,-12.5000,33.7800
-0.4504,-12.5000,33.8200
-0.4638,-12.5000,33.8600
Upvotes: 1
Views: 2324
Reputation: 530970
Remove the DOS line endings from the data files (file*.txt
?) before combining them.
Upvotes: 3