I would like to pass the output list of elements of a command as a parameter of another command. I have found some other pages:
- How to display the output of a Linux command on stdout and also pipe it to another command?
- Use output of bash command (with pipe) as a parameter for another command
but they seem to be more complex.
I just would like to copy a file to every result of a call to the Linux find command.
What is wrong here?:
find . -name myFile 2>&1 | cp /home/myuser/myFile $1
Thanks
This is what you want:
A breakdown / explanation of this:
find: invoking the find command.: start search from current working directory.-name myFile: find files with the explicit namemyFile-exec: for the search results, perform additional commands with themcp /home/myuser/myFile {}: copies/home/myuser/myFileto overwrite each result returned byfindto ; think of{}as where each search result goes.';': used to separate different commands to be run afterfind