Results 1 to 8 of 8

Thread: How To Combine Commands in Linux

  1. #1
    Join Date
    Jun 2012
    Beans
    19

    Question How To Combine Commands in Linux

    How do i combine commands like for example if i wanted to combine
    Code:
    cd /home
    and
    Code:
    cd /media
    consecutively. Is there a specific symbol or something of the sort?

  2. #2
    Join Date
    Nov 2008
    Location
    S.H.I.E.L.D. 6-1-6
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: How To Combine Commands in Linux

    Quote Originally Posted by vokevybez View Post
    How do i combine commands like for example if i wanted to combine
    Code:
    cd /home
    and
    Code:
    cd /media
    consecutively. Is there a specific symbol or something of the sort?
    There is a syntax to
    a) Run commands one after the other (only if the command before it is successful)
    b) Run commands all at once.

    a) uses "&&"

    For example,
    Code:
    cd /root && touch test && touch test2
    That would run one command after the other

    b) uses "&"

    For example
    Code:
    cd /root & touch test & touch test2
    That would run all of them at once, and would probably not be advisable.
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  3. #3
    Join Date
    Jun 2012
    Beans
    19

    Smile Re: How To Combine Commands in Linux

    Thanks a lot this will help with my bash tutorial
    Last edited by vokevybez; July 6th, 2012 at 03:03 PM.

  4. #4
    Join Date
    Oct 2005
    Location
    /root
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: How To Combine Commands in Linux

    c) Run the commands sequentially, regardless if the previous command in the chain was successful or not: use the semicolon.

    Code:
    cd /home ; ls -l ; cd /root ; ls -l

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

    Re: How To Combine Commands in Linux

    Most of the information has been presented here for you but the gruesome details can be seen in the bash man pages under 'Lists'.
    You think that's air you're breathing now?

  6. #6
    Join Date
    Jun 2012
    Beans
    19

    Talking Re: How To Combine Commands in Linux

    Quote Originally Posted by andrew.46 View Post
    Most of the information has been presented here for you but the gruesome details can be seen in the bash man pages under 'Lists'.
    thank you for your input the information covered is very comprehensive

  7. #7
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: How To Combine Commands in Linux

    Quote Originally Posted by andrew.46 View Post
    Most of the information has been presented here for you but the gruesome details can be seen in the bash man pages under 'Lists'.
    Real men read the man pages because they like learning about all those gruesome details! I'll admit the bash man page is a bit overwhelming though. The "grep" man page isn't far behind.

  8. #8
    Join Date
    Dec 2006
    Beans
    7,349

    Re: How To Combine Commands in Linux

    Another well written man page is the 'find' page, pity they are all not as well done .
    You think that's air you're breathing now?

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
  •