Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to copy a list of files into a single directory, but make the target directory the first filename in the command, how can I do it with linux command.

share|improve this question
    
The cp command will do what you want but the target directory must come after the souce file(s). Why do you want to change from the accepted standard? Try man cp for more info. –  Mike Fitzpatrick Sep 29 '11 at 4:55
add comment

2 Answers

On Linux, there is cp -t for xargs users.

xargs -d'\n' cp -t targetdir < filelist
share|improve this answer
add comment

Do you mean you the command to look like the following -

specialcopy destDir filetocopy1 filetocopy2 filetocopy3

if so, create a script called specialcopy.sh with below text

#!/bin/bash

DEST=$1
shift
cp "$@" "$DEST"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.