LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-22-2015, 08:37 PM   #1
johnty
LQ Newbie
 
Registered: Feb 2015
Location: Denver
Distribution: Debian
Posts: 2

Rep: Reputation: Disabled
cp $var1 var2 doesn't work


I'm running a bash script on a Raspberry Pi to control LED pixels. I'm stuck on a basic copy command.

I have a variable called nexttemp which contains the string B_254_TieDyeKaleidoscope.fseq

That file, in the same directory, is a large binary file that I'm trying to copy to a file called MasterFseq.fseq

If I do a

cp nexttemp MasterFseq.fseq

then MasterFseq.fseq contains the B_254_TieDyeKaleidoscope.fseq file name.

I want instead to have copied the binary file to MasterFseq.fseq.

It's my understanding that a $nexttemp will point to the binary file and not the name of it but when I do a

cp $nexttemp MasterFseq.fseq

the $nexttemp is thrown away and I'm told there is no destination file name, eg.

root@FPP:/home/pi/media/sequences# echo cp $nexttemp MasterFseq.fseq
+ echo cp MasterFseq.fseq
cp MasterFseq.fseq

How do I get the binaray file, which is named in nexttemp, copied to MasterFseq.fseq?

John
 
Old 02-22-2015, 08:53 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,056

Rep: Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915Reputation: 1915
Looks like you have a file called nexttemp, not a variable.
What does "echo $nexttemp" give - I'm guessing nothing.
 
Old 02-22-2015, 11:32 PM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
root@FPP:/home/pi/media/sequences# echo cp $nexttemp MasterFseq.fseq
+ echo cp MasterFseq.fseq
cp MasterFseq.fseq
Your nexttemp variable is empty.

First set by:

Code:
export nexttemp="B_254_TieDyeKaleidoscope.fseq"
Then execute the copy command.

Last edited by veerain; 02-22-2015 at 11:34 PM.
 
Old 02-23-2015, 11:29 AM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,362

Rep: Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004Reputation: 2004
Quote:
Originally Posted by veerain View Post
First set by:

Code:
export nexttemp="B_254_TieDyeKaleidoscope.fseq"
Then execute the copy command.
There's no reason for export, just set the variable normally, unless it needs to be used by subprocesses as well.
 
Old 02-23-2015, 08:16 PM   #5
johnty
LQ Newbie
 
Registered: Feb 2015
Location: Denver
Distribution: Debian
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Looks like you have a file called nexttemp, not a variable.
What does "echo $nexttemp" give - I'm guessing nothing.
Oh, exactly right. An echo command shows nothing. Somewhere in my parsing and manipulation of the target character string, the variable became a file. Making it a variable again does indeed work with the cp $var command.

Brain fade is so discouraging. Thanks for everyone's input. Great forum.
 
  


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
Convert .../($var1|$var2)/... regex to string smartgig Linux - Newbie 6 08-02-2012 10:59 AM
diff $Var1 $Var2 ? Xeratul Programming 8 01-13-2012 03:49 PM
[SOLVED] Trying to concatenate two variables and a slash ($var1/$var2). jbulgier Linux - General 2 12-13-2011 11:52 PM
Keyboard doesn't work right click on mouse doesn't work ramblinrick Linux Mint 2 10-15-2010 02:10 AM
bash: how to divide complex : FINAL=`[ ($var2 - $var1 ) / $var1 * 100 ]` frenchn00b Programming 9 11-06-2008 11:04 AM


All times are GMT -5. The time now is 11:51 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration