Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: How to zip a folder but not include it's parent directories?

  1. #11
    Join Date
    Aug 2008
    Location
    Behind the 8 ball
    Posts
    116

    Default Re: How to zip a folder but not include it's parent directories?

    Forget that last post, that won't help.
    I think zip doesn't like your current working directory.
    Change to root's home and then run the command.

    Code:
    cd /root/
    zip -jr /root/Desktop/backupqueue/txhttp/$(date +%F).zip /root/Desktop/rsyc_cache/txhttp/
    Sorry about that.

    Good luck,
    Hiatt

  2. #12

    Default Re: How to zip a folder but not include it's parent directories?

    Quote Originally Posted by hcvv View Post
    Code:
    cd /root/Desktop/administration/
    zip -r backup
    PS. /root/Desktop seems a strange place to me to use for anything. Because root NEVER logs in in the GUI and that directory should accordingly never be used for it's real purpose.
    your solution worked! Thanks!

  3. #13
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,996

    Default Re: How to zip a folder but not include it's parent directories?

    Quote Originally Posted by jthiatt08 View Post
    Use backticks instead.

    Code:
    zip -jr /root/Desktop/backupqueue/txhttp/`date +%F`.zip /root/Desktop/backupqueue/txhttp/
    Good luck,
    Hiatt
    Back ticks are only an old fashioned way of doing this. Thus nothing will be different as the result.
    Henk van Velden

  4. #14
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,996

    Default Re: How to zip a folder but not include it's parent directories?

    Quote Originally Posted by abacabb View Post
    your solution worked! Thanks!
    As I told you in post #2
    Henk van Velden

  5. #15

    Default Re: How to zip a folder but not include it's parent directories?

    Quote Originally Posted by hcvv View Post
    As I told you in post #2
    I'm an airhead sometimes.

  6. #16
    Join Date
    Aug 2008
    Location
    Behind the 8 ball
    Posts
    116

    Default Re: How to zip a folder but not include it's parent directories?

    Quote Originally Posted by hcvv View Post
    Back ticks are only an old fashioned way of doing this. Thus nothing will be different as the result.
    Thanks, I realized that after I posted, as I mentioned in post #11
    I didn't know backticks were old fashioned, I guess that makes me old fashioned.

  7. #17
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,996

    Default Re: How to zip a folder but not include it's parent directories?

    Quote Originally Posted by jthiatt08 View Post
    I didn't know backticks were old fashioned, I guess that makes me old fashioned.
    Not per se. It is on of those urban legends that is given down from one innocent noob to the next. Those people may however be very much up to date on other subjects.

    It was that way in the Bourne shell. Allready the Korn shell (about 25 years ago) offered the $( ... ) feature, which has imho the advantages that it
    . is better readable (especialy when a command/script also uses a multitude of ' and " quoting;
    . can be nested.
    Henk van Velden

  8. #18
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: How to zip a folder but not include it's parent directories?

    Actually according to the bash man page you can nest backticks also, by escaping them with \, but I'm not interested in using this feature. Presumably if you want to nest on the second level, you would need to escape the \ too. Getting too much like watching Inception. Try this:

    echo `echo foo\`echo bar\``

  9. #19
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,996

    Default Re: How to zip a folder but not include it's parent directories?

    Yep, works. I doubt if this works in the Bourne shell (but who has a Bourne shell nowadays). And since the Korn shell I happily use the $( ... ). No incentive to go back because the readability of
    Code:
    echo $(echo foo$(echo bar))
    is still much better imho.
    Henk van Velden

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •