LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 07: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, 07:53 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Looks like you have a file called nexttemp, not a variable.
What does "echo $nexttemp" give - I'm guessing nothing.
 
Old 02-22-2015, 10: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 10:34 PM.
 
Old 02-23-2015, 10:29 AM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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, 07: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



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

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

All times are GMT -5. The time now is 01:56 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