Register
It is currently Fri Oct 31, 2014 8:18 am

gpsbabel and spliting


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Oct 13, 2011 12:02 am   

Joined: Wed Oct 12, 2011 11:48 pm
Posts: 2
I want to merge all gpx files from folder and that could be done with command.
Code:
gpsbabel -i gpx `ls upload/*.gpx | sed "s/^/-f /g"` -o gpx -F sve.gpx


This works but there is problem when there is file with space in the name. I have tried to use quotas with command
Code:
gpsbabel -i gpx `ls upload/*.gpx | sed "s/^/-f \'/g" | sed "s/$/'/g"` -o gpx -F sve.gpx

but than:
Code:
GPX: Cannot open file ''upload/1b'!


I have figured out that there is problem with word splitting in command substitution but I couldn't find solution.
Could anyone help me?


Top
 Profile  
 PostPosted: Thu Oct 13, 2011 1:43 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Code:
for file in upload/*.gpx ; do
    echo -n " -f '$file'"
done | sed '
s/^/gpsbabel -i gpx/;
s/$/ -o gpx -F sve.gpx/' | bash


Top
 Profile  
 PostPosted: Thu Oct 13, 2011 2:18 pm   

Joined: Wed Oct 12, 2011 11:48 pm
Posts: 2
It works wit eval:
Code:
eval gpsbabel -i gpx `ls upload/*.gpx | sed "s/^/-f \'/g" | sed "s/$/'/g"` -o gpx -F sve.gpx


Thanks


Top
 Profile  
 PostPosted: Thu Oct 13, 2011 9:42 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 551
hi,

Code:
gpsbabel -i gpx $(printf -- '-f %q ' upload/*.gpx) -o gpx -F sve.gpx
should do it.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: popeye and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP