

Where ‘INTYPE’ and 'OUTTYPE' are formats that GPSBabel understands and 'INFILE' and ‘OUTFILE’ are the locations of that data. Gpsbabel -i INTYPE -f INFILE -o OUTTYPE -F OUTFILE
#Gpsbabel output locations serial#

If pattern begins with /, all matches of pattern are replaced with string. Parameter is expanded and the longest match of pattern against its value is replaced with string. The pattern is expanded to produce a pattern just as in pathname expansion. We'll use the bash-specific find-and-replace syntax, described in the bash manual: (I highlighted the two features this solution uses) In that case, you only need to change the list of arguments by prepending -f to each one, so that the argument list becomes, in effect: "-ffile 1.gpx" "-ffile 2.gpx" gpsbabel appears to not use standard posix or gnu libraries for argument parsing, but I believe it still gets this right.Īpparently, your script expects its arguments to be a list of filenames presumably, if the filenames include whitespace, you will quote the names which include whitespace. If the utility uses either getopt or getopt_long, this is automatic. You are making things way more complicated for yourself than they need to be.Īny reasonably posix/gnu-compatible utility which takes an option in the form of two command-line arguments ( -f STRING, or equivalently -f FILENAME) should also accept a single command-line argument -fSTRING. #/bin/bashĮcho "Number of files:" List of the datafile to treat (each name protected with a ') I get an error from gpsbabel "Extra arguments on command line" suggesting that I made a mistake in the variable usage. I got lost in the bash substitution and wrote and more sequenced bash for debugging purpose with no success. So I tried to modify this script to handle also filename with containing spaces. Gpsbabel -i gpx $(echo $* | for GPX do echo -n " -f $GPX " done) \ Here is a script working for file with no spaces in their name #!/bin/bash It means that the sequence -f "name_of_the_input_file" has to be repeated for each input file passed from the batch parameters. I am trying to write a batch to run this syntax with a number of input file not known initially. The input data files are listed after -f, and the resulting file after -F The input format of the GPS data is given by -i, the output format by -o. The syntax for my purpose and which is working is: gpsbabel -i gpx -f "file 1.gpx" -f "file 2.gpx" -o gpx -F output.gpx -x track,merge
#Gpsbabel output locations software#
Gpsbabel is software which permit merging of tracks recorded by gps devices. Any help or insight from bash programmers will be much appreciated. I am stuck to handle files with name containing (white) spaces. I am trying to program a script to run gpsbabel.
