Escaping Bash wildcards when executing python script from bash script? -


i've got bash script defines array of file globs containing * wildcards.

the script executes python script passing each of these globs parameter.

on command line can quote entire glob, , python happy it.

in bash script, if quote globs, python's os.path.realpath seems confused quotes - passed in script itself.

e.g. bash script:

backup_paths=("/root/backups/db-dump-*" "/root/backups/*_backup.tar.bz2") path in "${backup_paths[@]}"   /usr/local/bin/python2.7 /usr/local/bin/clean.py \'$path\' $max_files done 

python:

os.path.realpath(path)    # results in like: /usr/local/bin'/root/backups/db-dump-*' 

how can make them play together?

thanks

instead of \'$path\', use "$path". double-quotes allow contents of variable $path substituted, prevent wildcard expansion , ensure path passed single argument.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -