tar’ed and feathered

I did a dumb thing this morning.

tar cvf reference.doc images questions.doc stuff.doc files.tar

What I was trying to do was create a tar file with my doc files and my images in it so I could scp it from my work computer to my home computer. The tar file was going to be called files.tar. But as any basic unix weenie will tell you, that’s not the right syntax. The tar file you’re creating is supposed to be the first filename in the list. In fact, what this syntax will do is open reference.doc for writing, deleting the existing contents, stick images questions and stuff into it, and then complain it can’t find files.tar. Reference.doc: gone. Poof.

Never mind that reference.doc was actually the really important file there and the one I had been working on for more than a week. And of course yesterday when I was at work I had been working on a new computer where I had not configured Word to create an automatic backup, nor is that computer backed up at night. Nor did I do what I have told a half dozen clients to do over the last few years — create a source code control system for your docs and use it. Well. Sux2bMe.

Fortunately I do have a copy here at home so I only lost a day’s work. Alas, it was a day of nitpicky changes across the whole document, the sort of thing I hate to do the first time let alone twice.

From Stupid Unix Mistakes done in previous years I have tcsh set to noclobber, and rm aliased to ‘mv !$ ~/trash/’ (well, its a script, but that’s the idea). Now I guess I need to do something about tar.


4 thoughts on “tar’ed and feathered

  1. The tar file is the first thing after the “f” argument, so you could actually do:

    tar -cv *.files -f foo.tar

    If you like putting the filename last.

    I like breaking out the arguments like that just so it’s obvious what’s doing what. This makes me an Uncool Unix Person and all the Real Unix Geeks make fun of me.

  2. Thanks for reporting your mistake – I have made the same before, not so much fun, really.
    I followed your hint and defused rm.
    Kind regards

  3. It just goes to prove the old saying…”Unix *is* user-friendly…it’s just selective about who its friends are.” 🙂

    I’ve done the same, and far worse, in my day. You have my sympathies.

Comments are closed.