Results 1 to 10 of 10

Thread: touch command confusion with "&& \"

  1. #1
    Join Date
    Feb 2012
    Location
    Los Angeles, CA
    Beans
    138
    Distro
    Ubuntu 12.04 Precise Pangolin

    touch command confusion with "&& \"

    I am currently setting up mutt on my Ubuntu 12.04 machine. I want to verify something about the following commands, used to set up msmtp.

    Code:
    touch $HOME/.msmtprc && \
    touch $HOME/.msmtp.log && \
    chmod 0600 $HOME/.msmtprc
    What does "&& \" do? I don't know if they're relevant.
    John J. Kim (IRC: kotux)
    High School Senior / Ubuntu User # 35405
    www.launchpad.net/~kotux
    "Let your performance do the thinking." --Charlotte Bronte


  2. #2
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: touch command confusion with "&& \"

    The && will run the next command if the first one was successful. .So if the first touch was successful, run the second touch. If that was successful, too, then do the chmod.

    The \ means that it continues on the next line. So this is equivalent to the above:

    Code:
    touch $HOME/.msmtprc && touch $HOME/.msmtp.log && chmod 0600 $HOME/.msmtprc
    You can see && and || in action:

    Code:
    /bin/true && echo OK || echo fail
    /bin/false && echo OK || echo fail
    /bin/true always succeeds, /bin/false always fails.

  3. #3
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: touch command confusion with "&& \"

    EDIT: D'oh! Lars Noodén beat me to it.

    && is a control or list operator; it represents a logical AND:
    Code:
    command1 && command2
    command2 is executed if, and only if, the execution of command1 was successful.

    The sequence \<newline> is treated as a line continuation:

    See:
    http://mywiki.wooledge.org/BashGuide...ndConditionals
    and
    http://wiki.bash-hackers.org/syntax/quoting

  4. #4
    Join Date
    Feb 2012
    Location
    Los Angeles, CA
    Beans
    138
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: touch command confusion with "&& \"

    Ah ok, I see that the commands are meant to be "copy-pasted." Thanks!
    John J. Kim (IRC: kotux)
    High School Senior / Ubuntu User # 35405
    www.launchpad.net/~kotux
    "Let your performance do the thinking." --Charlotte Bronte


  5. #5
    Join Date
    Dec 2006
    Beans
    7,317

    Re: touch command confusion with "&& \"

    I suspect that you are following an old guide of mine:

    https://help.ubuntu.com/community/MuttAndGmail

    Good to see it still is useful
    You think that's air you're breathing now?

  6. #6
    Join Date
    Aug 2011
    Location
    Melbourne, Australia.
    Beans
    Hidden!
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: touch command confusion with "&& \"

    Quote Originally Posted by andrew.46 View Post
    I suspect that you are following an old guide of mine:

    https://help.ubuntu.com/community/MuttAndGmail

    Good to see it still is useful
    Hi andrew.46

    Might I suggest you do a minor update to your page to retain it within NewDocs which has an 18 month edit limit at present.

    Perhaps you could check the URL on your external Link which came up with a 404 error on my check.

    Regards,

    BlinkinCat
    Last edited by BlinkinCat; February 27th, 2014 at 07:34 AM.

  7. #7
    Join Date
    Dec 2006
    Beans
    7,317

    Re: touch command confusion with "&& \"

    Quote Originally Posted by BlinkinCat View Post
    Might I suggest you do a minor update to your page to retain it within NewDocs which has an 18 month edit limit at present.

    Perhaps you could check the URL on your external Link which came up with a 404 error on my check.
    The 404 is from old website which is now defunct unfortunately. I only really maintain a vlc guide on these Forums at the moment, but that page is a wiki so anybody can jump in and alter things as they see fit. The basic information should be pretty sound still...
    You think that's air you're breathing now?

  8. #8
    Join Date
    Aug 2011
    Location
    Melbourne, Australia.
    Beans
    Hidden!
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: touch command confusion with "&& \"

    Quote Originally Posted by andrew.46 View Post
    The 404 is from old website which is now defunct unfortunately. I only really maintain a vlc guide on these Forums at the moment, but that page is a wiki so anybody can jump in and alter things as they see fit. The basic information should be pretty sound still...
    If I remove the link that should retain an up to date edit if that is O.K. with you.

  9. #9
    Join Date
    Dec 2006
    Beans
    7,317

    Re: touch command confusion with "&& \"

    Quote Originally Posted by BlinkinCat View Post
    If I remove the link that should retain an up to date edit if that is O.K. with you.
    Thanks for going to the trouble
    You think that's air you're breathing now?

  10. #10
    Join Date
    Aug 2011
    Location
    Melbourne, Australia.
    Beans
    Hidden!
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: touch command confusion with "&& \"

    Quote Originally Posted by andrew.46 View Post
    Thanks for going to the trouble
    It is no trouble whatsoever!

    The main issue is that you still consider the page relevant today.

    Cheers -

Tags for this Thread

Bookmarks

Posting Permissions

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