copying files resulting from using grep into a new folder
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
I have a question concerning the concatenation of two processes in the terminal. I have a folder with over 50.000 files. I used grep to look for those files containing a specific term:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files
which gives me a huge list like this:
/var/cqp/upload/heideko/import_files/26629.vrt
/var/cqp/upload/heideko/import_files/32862.vrt
I need to copy the resulting files into a new folder. I was thinking something like:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | cp * bio_files/
My try might not make any sense. I'm just starting with the terminal. I just want to copy the files resulting from my grep search into a new folder called bio_files. I realised that what I get from grep is just the names of the files. But I want to use those names as input for the cp command. Any help is highly appreciated.
command-line grep
add a comment |Â
up vote
0
down vote
favorite
I have a question concerning the concatenation of two processes in the terminal. I have a folder with over 50.000 files. I used grep to look for those files containing a specific term:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files
which gives me a huge list like this:
/var/cqp/upload/heideko/import_files/26629.vrt
/var/cqp/upload/heideko/import_files/32862.vrt
I need to copy the resulting files into a new folder. I was thinking something like:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | cp * bio_files/
My try might not make any sense. I'm just starting with the terminal. I just want to copy the files resulting from my grep search into a new folder called bio_files. I realised that what I get from grep is just the names of the files. But I want to use those names as input for the cp command. Any help is highly appreciated.
command-line grep
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a question concerning the concatenation of two processes in the terminal. I have a folder with over 50.000 files. I used grep to look for those files containing a specific term:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files
which gives me a huge list like this:
/var/cqp/upload/heideko/import_files/26629.vrt
/var/cqp/upload/heideko/import_files/32862.vrt
I need to copy the resulting files into a new folder. I was thinking something like:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | cp * bio_files/
My try might not make any sense. I'm just starting with the terminal. I just want to copy the files resulting from my grep search into a new folder called bio_files. I realised that what I get from grep is just the names of the files. But I want to use those names as input for the cp command. Any help is highly appreciated.
command-line grep
I have a question concerning the concatenation of two processes in the terminal. I have a folder with over 50.000 files. I used grep to look for those files containing a specific term:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files
which gives me a huge list like this:
/var/cqp/upload/heideko/import_files/26629.vrt
/var/cqp/upload/heideko/import_files/32862.vrt
I need to copy the resulting files into a new folder. I was thinking something like:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | cp * bio_files/
My try might not make any sense. I'm just starting with the terminal. I just want to copy the files resulting from my grep search into a new folder called bio_files. I realised that what I get from grep is just the names of the files. But I want to use those names as input for the cp command. Any help is highly appreciated.
command-line grep
edited May 15 at 16:22
muru
129k19271460
129k19271460
asked May 15 at 16:00
![](https://lh5.googleusercontent.com/-KotpbOTdPks/AAAAAAAAAAI/AAAAAAAAAag/vXTzGuycSQ8/photo.jpg?sz=32)
![](https://lh5.googleusercontent.com/-KotpbOTdPks/AAAAAAAAAAI/AAAAAAAAAag/vXTzGuycSQ8/photo.jpg?sz=32)
Carolina Cárdenas
31
31
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Use xargs
and the -t
option of cp
:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs cp -t bio_files/
If your files might have spaces in their names, then make everything null-delimited:
grep -inrlZ "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs -0 cp -t bio_files/
Thank you. That worked! I'll read more aboutxargs
!
â Carolina Cárdenas
May 15 at 16:31
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Use xargs
and the -t
option of cp
:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs cp -t bio_files/
If your files might have spaces in their names, then make everything null-delimited:
grep -inrlZ "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs -0 cp -t bio_files/
Thank you. That worked! I'll read more aboutxargs
!
â Carolina Cárdenas
May 15 at 16:31
add a comment |Â
up vote
3
down vote
accepted
Use xargs
and the -t
option of cp
:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs cp -t bio_files/
If your files might have spaces in their names, then make everything null-delimited:
grep -inrlZ "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs -0 cp -t bio_files/
Thank you. That worked! I'll read more aboutxargs
!
â Carolina Cárdenas
May 15 at 16:31
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Use xargs
and the -t
option of cp
:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs cp -t bio_files/
If your files might have spaces in their names, then make everything null-delimited:
grep -inrlZ "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs -0 cp -t bio_files/
Use xargs
and the -t
option of cp
:
grep -inrl "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs cp -t bio_files/
If your files might have spaces in their names, then make everything null-delimited:
grep -inrlZ "Bioethik_Debatte" /var/cqp/upload/heideko/import_files | xargs -0 cp -t bio_files/
answered May 15 at 16:11
steeldriver
62.2k1196164
62.2k1196164
Thank you. That worked! I'll read more aboutxargs
!
â Carolina Cárdenas
May 15 at 16:31
add a comment |Â
Thank you. That worked! I'll read more aboutxargs
!
â Carolina Cárdenas
May 15 at 16:31
Thank you. That worked! I'll read more about
xargs
!â Carolina Cárdenas
May 15 at 16:31
Thank you. That worked! I'll read more about
xargs
!â Carolina Cárdenas
May 15 at 16:31
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036597%2fcopying-files-resulting-from-using-grep-into-a-new-folder%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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