DSL Ideas and Suggestions :: "Add to filetool.lst" button
WoofyDugFock, I was really impressed by your code. I learned a lot from the simplicity of your use of && and ||, as well as being able to use |'s rather than /'s in sed. I didn't know that. Having the error displayed after the procedure was really an eye opener for me. I know I'll be doing that myself in the future. I got duplicates when I tried your code though. When I had the same files selected, I got multiple entries in filetool.lst when I hit the button multiple times.
If join works eliminating duplicates, then what was the problem with a duplicated filetool.lst? Why should you need the extra sed statements? Do all files get duplicated?
I went back to sort and uniq to change your code to:
Code Sample
a=~/filetool.lst && echo "Backup list:" && for i in %f; do echo %d/$i |sed "s/^\/\(ramdisk\)*\/*//" >> $a; done && cat $a | sort | uniq | tee $a && echo "Done." || echo "Error"
I didn't get duplicates, and filetool.lst wasn't repeated either.
The raw example is great: it's like a little microcosm of bash wonders.Thanks heaps for your encouraging remarks, Clacker. I was beginning to wish I'd never opened my big fat mouth! Oh, these stumbling steps into bashhood!
Vertical pipes in sed? I think you must be referring to my censored previous post - you must have been quick and read it before I deleted the "fix" - I found the same annoying bug myself so went back and plucked the foul offensive thing out! (The one with the echo at the front as you have it and the tee ..?).
I came to the same conclusion about |sort|uniq for appending rather than overwriting - I've been trying today to make join work for appending inside the do loop ( "join -v 1 - $a | tee -a $a etc )" but I'm tired of the buggy issues.
If it is of interest, I found getting rid of "join -v 1 - $a" writing filetool.lst's own name to $a though can be done - change the sed filter so that it blocks that filename -
Code Sample
sed "s|^/\(ramdisk\)*/*\($a\)*||;/^$/d"
The verticle pipes I was talking about was using the form
sed "s|whatever|whatevuh|"
instead of
sed "s/whatever/whatevuh/"
That helps with using /'s in the "whatever" sections. I was using the \ character way to much because I didn't know you could start off and end using the | character.
original here.