You can’t do this with cp
alone but you can combine cp
with xargs
:
echo dir1 dir2 dir3 | xargs -n 1 cp file1
Will copy file1
to dir1
, dir2
, and dir3
. xargs
will call cp
3 times to do this, see the man page for xargs
for details.
More Related Contents:
- How do I test if a variable is a number in Bash?
- What does set -e mean in a bash script?
- What’s the magic of “-” (a dash) in command-line parameters?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Is there a “goto” statement in bash?
- Forcing bash to expand variables in a string loaded from a file
- Script parameters in Bash
- How can I generate new variable names on the fly in a shell script?
- Bash script processing limited number of commands in parallel
- Bash while read loop extremely slow compared to cat, why?
- Redirect STDERR / STDOUT of a process AFTER it’s been started, using command line?
- Find multiple files and rename them in Linux
- Avoid gnome-terminal close after script execution?
- How can I loop over the output of a shell command?
- Why does /bin/sh behave differently to /bin/bash even if one points to the other?
- How can I kill a process by name instead of PID, on Linux? [duplicate]
- [ :Unexpected operator in shell programming [duplicate]
- Using the passwd command from within a shell script
- Command to get time in milliseconds
- Bash Script – iterating over output of find
- Linux/Unix command to determine if process is running?
- Syntax with pound and percent sign after shell parameter name [duplicate]
- Insert multiple lines into a file after specified pattern using shell script
- Bash: wait with timeout
- Randomly shuffling lines in Linux / Bash
- Get ceiling integer from number in linux (BASH)
- How can I trim white space from a variable in awk?
- How do you filter out all unique lines in a file?
- Counter increment in Bash loop not working
- How to pass parameters to a Bash script?