Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- export IFS=$'\n' #Treat spaces as... spaces!
- ddir=$HOME/Flashes #Destination directory
- mkdir -p "$ddir" 2>/dev/null #...create it,eventually
- pref="FlashDownload" #Prefix name
- dp="$ddir"/"$pref" #destdir/prefixname
- for s in $(find /proc/*/fd/ -lname "/tmp/Flash*" 2>/dev/null); do
- pt=$(readlink "$s"|cut -f 1 -d " ") #Get real flash name
- d=$dp$(basename "$pt") #FullPath/Prefix+RealFlashName
- if [ ! -f "$d" ] #Download if the file does not exists
- then
- p=$(echo "$s"|cut -d "/" -f 3) #get the pid
- echo tailing "$s" to "$d" from pid $p
- tail -n +0 --pid=$p --follow "$s" > "$d" & #copy using tail
- else
- echo File "$pt" is downloaded/downloading #...skip if the file exists
- fi
- done
Add Comment
Please, Sign In to add comment