Skip to content

Instantly share code, notes, and snippets.

@patsma
Created February 28, 2021 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patsma/c7ae3bec6da909f7f37abaf143ad0e9a to your computer and use it in GitHub Desktop.
Save patsma/c7ae3bec6da909f7f37abaf143ad0e9a to your computer and use it in GitHub Desktop.
Why not cp to location 1, then mv to location 2. This takes care of "removing" the original.
And no, it's not the correct syntax. | is used to "pipe" output from one program and turn it into input for the next program. What you want is ;, which seperates multiple commands.
cp file1 file2 ; cp file1 file3 ; rm file1
If you require that the individual commands MUST succeed before the next can be started, then you'd use && instead:
cp file1 file2 && cp file1 file3 && rm file1
That way, if either of the cp commands fails, the rm will not run.
@patsma
Copy link
Author

patsma commented Feb 28, 2021

Chain commands bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment