Skip to main content

Never trust a bunny!!

· One min read

Ok, I screwed up!! I was playing with an xargs command in order to process, then delete, some files. Since I was still "developing" the command, I was simply echo'ing the commands rather than running them... here's what I ran...

ls -1 | xargs -I{} bash -c 'echo cat {} /usr/local/bin/ ; rm {}'

Do you see the problem?! So easy to do :( While I correctly echo'ed the first part of the Bash command, I also needed another echo in front of the rm... without it, the not-so-dry run went ahead an deleted all my files, without first processing them!! I guess in my mind, I'd carelessly assumed that the full Bash echo'd since it's enclosed within single-quotes... oops! One must be extra careful when executing bash -c commands :(

Ah well, now I'm in the process of exporting the lost data from another source, in preparation of re-processing.

Oh, and I've added the above files to our daily backup scripts too.