LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-13-2014, 05:38 AM   #1
jonnybinthemix
Member
 
Registered: May 2014
Location: Bristol, United Kingdom
Distribution: RHEL 5 & 6
Posts: 169

Rep: Reputation: Disabled
Quick BASH Question


Hey Guys,

Just a real quick BASH question that I'm sure will be simple but it's holding me up from testing something relating to the other threat I've got...

If I have a list of file locations in a variable, how can I print the contents of that variable into a copy command?

For example:

cat $FILES would display:

./file1
./file2

But in the script I'd like to do something like
Code:
cp file1 file2 /tmp
I've tried:

Code:
cat $FILES | cp - /tmp
Code:
 
cat $FILES | cp <&1 /tmp
Code:
cp $FILES /tmp
none of the above work and I can see why.. but is there something that I'm missing?

Thanks
Jon
 
Old 06-13-2014, 05:46 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
cp cannot accept any input from stdin, therefore piping into cp has no any meaning.
You can try cp $(cat $FILES) /tmp
 
2 members found this post helpful.
Old 06-13-2014, 07:55 AM   #3
jonnybinthemix
Member
 
Registered: May 2014
Location: Bristol, United Kingdom
Distribution: RHEL 5 & 6
Posts: 169

Original Poster
Rep: Reputation: Disabled
Thanks that worked

Appreciate your help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Quick bash prompt colour question (changing styles) steak1987 Linux - Software 4 01-29-2014 09:10 AM
Quick Bash question for a hosting company webjive Linux - Server 13 12-01-2011 06:47 PM
A quick bash question Ander Linux - Newbie 6 05-05-2006 02:13 AM
Quick bash question neocytrix Programming 8 07-30-2004 10:23 PM
really quick bash question fibbi Linux - Software 3 06-15-2004 10:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration