linux - Bash, wget remove comma from output filename -
i reading file url's line line pass url wget:
file=/home/img-url.txt while read line; url=$line wget -n -p /home/img/ $url done < $file
this works, file contains comma in filename. how can save file without comma?
example:
http://xy.com/0005.jpg -> saved 0005.jpg http://xy.com/0022,22.jpg -> save 002222.jpg not 0022,22
i hope find question interesting.
update:
we have nice solution, there solution time stamping error?
warning: timestamping nothing in combination -o. see manual details.
this should work:
url="$line" filename="${url##*/}" filename="${filename//,/}" wget -p /home/img/ "$url" -o "$filename"
using -n , -o both throw warning message. wget manual says:
-n (for timestamp-checking) not supported in combination -o: since file newly created, have new timestamp.
so, when use -o option, creates new file new timestamping , -n
option becomes dummy (it can't for). if want preserve timestapming, workaround might this:
url="$line" wget -n -p /home/img/ "$url" file="${url##*/}" newfile="${filename//,/}" [[ $file != $newfile ]] && cp -p /home/img/"$file" /home/img/"$newfile" && rm /home/img/"$file"
Comments
Post a Comment