One limitation of using xargs to run multiple commands is that the arguments you send to the command using echo will always be tacked to the end of the command that is run, so you can’t use the same technique to copy three files to a single directory. As a comparison, if you ran a command like this, you would see three arguments per line: $ echo Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec | xargs -n 3 The -n ensures that each command will use only one of the arguments provided by the echo command in each of the commands that xargs runs. The -v argument ensures that you will see a list of the files being copied. In this case, the xargs command uses the information you provide (the directory names) to compose each of the three commands required to copy the files to the three directories. # single file to multiple dirs # multiple files to single dirĪnother option is to use the xargs command to copy your file to multiple directories: $ echo dir1 dir2 dir3 | xargs -n 1 cp -v myfile
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |