csv - bash homedir/multiple replacements? -
i converting xls files csv , need extract few things out of filename, looks ~/foo2008-2012tmpl.xls. need 2008 , foo2008-2012tmpl.csv script when called foo. current version is:
file=(~/$1*tmpl*xls) year=${file/*$1/} year=${year/-20??tmpl.xls/} loffice "-env:userinstallation=file:///tmp/libo_conversion" --headless --convert-to csv $file --outdir . localfile=$(basename $file) csvfile=${localfile/xls/csv} which works it's not pretty. possible multiple string replacements bash in 1 go or way year out of filename? tried extglob moment added | never matched :/
similarly, way remove /home/chx/...xls part in 1 go $file?
could be:
year=$(expr "$file" : ".*$1\(....\)")
Comments
Post a Comment