Find the answer to your Linux question:
Results 1 to 4 of 4
I already know how to move 1 or more files at the same time from 1 folder to another and how to move a single folder from 1 directory to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    67

    Using multiple commands in a single command


    I already know how to move 1 or more files at the same time from 1 folder to another and how to move a single folder from 1 directory to another. But, I'm now trying to see if and how I can perform multiple steps in a command using command line. So, I have 3 questions. Using the command line....
    1) If possible, what is the command to move 2 or more folders from 1 directory to another at the same time? (assume folders have similar names and completely different names)

    and to take it a step further, 2) If I wanted to make a new folder in another directory to put those 2+ folders in, what is the command to make the folder while those 2+ folders are in process of moving to that new folder? (again, assume folders have similiar and completely different names) If that's even possilbe to do.

    And 3) Is it possible to join multiple commands together even if they have nothing in common? For example, if I wanted to make a new folder in /root directory, then move a file from 1 folder to another (nothing to do with the /root directory) and then delete a file in another directory (nothing to do with /root or the folders I just moved the file to and from), how would I go about joining those commands? Is there a certain symbol I can use like: | ; : & <-- or anything that can join the commands together?

    I've already tried some google searches but came up empty handed so I've come here. I appreciate any help. Thanks to all who answer.

  2. #2
    Linux Newbie raghaven.kumar's Avatar
    Join Date
    Mar 2008
    Location
    Bangalore, India
    Posts
    209
    try && for combining commands
    or you can make pipes with &#180;|&#180; like
    ps aux | grep mv
    to see all process containing &#180;mv&#180; letters in it.

  3. #3
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    Quote Originally Posted by Dark Nuker View Post
    And 3) Is it possible to join multiple commands together even if they have nothing in common? For example, if I wanted to make a new folder in /root directory, then move a file from 1 folder to another (nothing to do with the /root directory) and then delete a file in another directory (nothing to do with /root or the folders I just moved the file to and from), how would I go about joining those commands? Is there a certain symbol I can use like: | ; : & <-- or anything that can join the commands together
    You can use &&. && will execute the second command if the first one succeeds. If you need to relate the two processes somehow, the pipe operator that the previous poster mentioned will work. The pipe operator sends the stdout of the first command into the stdin of the second. However, if the pipe breaks (i.e. the first command failed), the second command will not be executed. But for two independent processes, && should work fine.

  4. #4
    Just Joined!
    Join Date
    Sep 2008
    Posts
    67
    Thanks for the help guys, really appreciate it. But stil curious about moving multiple folders at the same time into a single destination folder in a single command. How is that command setup?

Posting Permissions

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