Copying & Renaming Files with GNU Parallel
I have a simple script that I want to copy and rename files, in files.lst
based on a list of names in names.lst
**name.lst**
100GV200.vcf
150GV200.vcf
14300GV200.vcf
**file.lst**
file1.txt
file2.txt
file3.txt
My script so far looks like this:
parallel --link -k "cp {} {}" :::: file.lst :::: name.lst
Unfortunately I get back:
cp: target `100GV200.vcf` is not a directory
When I run a single cp
command in the terminal it works perfectly
cp file1.txt 100GV200.vcf
Where am I going wrong in understanding how GNU parallel reads in arguments?
gnu-parallel
add a comment |
I have a simple script that I want to copy and rename files, in files.lst
based on a list of names in names.lst
**name.lst**
100GV200.vcf
150GV200.vcf
14300GV200.vcf
**file.lst**
file1.txt
file2.txt
file3.txt
My script so far looks like this:
parallel --link -k "cp {} {}" :::: file.lst :::: name.lst
Unfortunately I get back:
cp: target `100GV200.vcf` is not a directory
When I run a single cp
command in the terminal it works perfectly
cp file1.txt 100GV200.vcf
Where am I going wrong in understanding how GNU parallel reads in arguments?
gnu-parallel
add a comment |
I have a simple script that I want to copy and rename files, in files.lst
based on a list of names in names.lst
**name.lst**
100GV200.vcf
150GV200.vcf
14300GV200.vcf
**file.lst**
file1.txt
file2.txt
file3.txt
My script so far looks like this:
parallel --link -k "cp {} {}" :::: file.lst :::: name.lst
Unfortunately I get back:
cp: target `100GV200.vcf` is not a directory
When I run a single cp
command in the terminal it works perfectly
cp file1.txt 100GV200.vcf
Where am I going wrong in understanding how GNU parallel reads in arguments?
gnu-parallel
I have a simple script that I want to copy and rename files, in files.lst
based on a list of names in names.lst
**name.lst**
100GV200.vcf
150GV200.vcf
14300GV200.vcf
**file.lst**
file1.txt
file2.txt
file3.txt
My script so far looks like this:
parallel --link -k "cp {} {}" :::: file.lst :::: name.lst
Unfortunately I get back:
cp: target `100GV200.vcf` is not a directory
When I run a single cp
command in the terminal it works perfectly
cp file1.txt 100GV200.vcf
Where am I going wrong in understanding how GNU parallel reads in arguments?
gnu-parallel
gnu-parallel
asked Feb 9 at 1:02
AMBAMB
254
254
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Use {1} and {2} notation:
parallel --link -k cp {1} {2} :::: file.lst :::: name.lst
Works for me, it will work with the quotes as well
parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst
To get it to work with {}, you would have had to do something like this:
parallel --link -k "cp {}" :::: file.lst :::: name.lst
Because parallel will automatically append the line of the two files.
Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst
– AMB
Feb 9 at 1:36
If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.
– NiteRain
Feb 9 at 1:50
add a comment |
Don't bother with parallel's deranged interface; for file names without special characters you can just go for
paste file.lst name.lst | xargs -n2 echo mv
add a comment |
I have used below command to achieve the same
paste file.lst name.lst| awk '{print "cp" " " $1 " " $2}'|sh
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499590%2fcopying-renaming-files-with-gnu-parallel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use {1} and {2} notation:
parallel --link -k cp {1} {2} :::: file.lst :::: name.lst
Works for me, it will work with the quotes as well
parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst
To get it to work with {}, you would have had to do something like this:
parallel --link -k "cp {}" :::: file.lst :::: name.lst
Because parallel will automatically append the line of the two files.
Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst
– AMB
Feb 9 at 1:36
If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.
– NiteRain
Feb 9 at 1:50
add a comment |
Use {1} and {2} notation:
parallel --link -k cp {1} {2} :::: file.lst :::: name.lst
Works for me, it will work with the quotes as well
parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst
To get it to work with {}, you would have had to do something like this:
parallel --link -k "cp {}" :::: file.lst :::: name.lst
Because parallel will automatically append the line of the two files.
Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst
– AMB
Feb 9 at 1:36
If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.
– NiteRain
Feb 9 at 1:50
add a comment |
Use {1} and {2} notation:
parallel --link -k cp {1} {2} :::: file.lst :::: name.lst
Works for me, it will work with the quotes as well
parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst
To get it to work with {}, you would have had to do something like this:
parallel --link -k "cp {}" :::: file.lst :::: name.lst
Because parallel will automatically append the line of the two files.
Use {1} and {2} notation:
parallel --link -k cp {1} {2} :::: file.lst :::: name.lst
Works for me, it will work with the quotes as well
parallel --link -k "cp {1} {2}" :::: file.lst :::: name.lst
To get it to work with {}, you would have had to do something like this:
parallel --link -k "cp {}" :::: file.lst :::: name.lst
Because parallel will automatically append the line of the two files.
edited Feb 9 at 1:57
answered Feb 9 at 1:31
NiteRainNiteRain
23514
23514
Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst
– AMB
Feb 9 at 1:36
If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.
– NiteRain
Feb 9 at 1:50
add a comment |
Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst
– AMB
Feb 9 at 1:36
If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.
– NiteRain
Feb 9 at 1:50
Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst
– AMB
Feb 9 at 1:36
Works perfectly. Why does {1} and {2} work but just empty {} not? I thought it would pull 1 argument from file.lst and the other from name.lst
– AMB
Feb 9 at 1:36
If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.
– NiteRain
Feb 9 at 1:50
If you don't specify which input is suppose to be used for the copy, parallel append, for example, if you remove the file 100GV200.vcf and you do this: mv file1.txt 100GV200.vcf file1.txt 100GV200.vcf, you will get the error you were getting. By telling parallel what line you want to go where, you get the move command as intended.
– NiteRain
Feb 9 at 1:50
add a comment |
Don't bother with parallel's deranged interface; for file names without special characters you can just go for
paste file.lst name.lst | xargs -n2 echo mv
add a comment |
Don't bother with parallel's deranged interface; for file names without special characters you can just go for
paste file.lst name.lst | xargs -n2 echo mv
add a comment |
Don't bother with parallel's deranged interface; for file names without special characters you can just go for
paste file.lst name.lst | xargs -n2 echo mv
Don't bother with parallel's deranged interface; for file names without special characters you can just go for
paste file.lst name.lst | xargs -n2 echo mv
answered Feb 9 at 1:20
n.cailloun.caillou
30816
30816
add a comment |
add a comment |
I have used below command to achieve the same
paste file.lst name.lst| awk '{print "cp" " " $1 " " $2}'|sh
add a comment |
I have used below command to achieve the same
paste file.lst name.lst| awk '{print "cp" " " $1 " " $2}'|sh
add a comment |
I have used below command to achieve the same
paste file.lst name.lst| awk '{print "cp" " " $1 " " $2}'|sh
I have used below command to achieve the same
paste file.lst name.lst| awk '{print "cp" " " $1 " " $2}'|sh
answered Feb 9 at 3:58
Praveen Kumar BSPraveen Kumar BS
1,490138
1,490138
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499590%2fcopying-renaming-files-with-gnu-parallel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown