LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-21-2014, 09:18 AM   #1
Osbian
LQ Newbie
 
Registered: Dec 2013
Posts: 6

Rep: Reputation: Disabled
Setting variable + command as a new variable Raspbian


Hi

I am trying to make a script using variables instead of long commands and paths. This is what i have for now:

Code:
skript='/home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver/Adafruit_DHT_Real 2302 4'
What I need is 2 more variables built from "skript".I have these lines at the moment

Code:
$skript | sed '1d' > /home/pi/humid.txt
$skript | sed '2d' > /home/pi/temp.txt
and need the
Code:
$skript | sed '1d'
to be a separate variable, as well as
Code:
$skript | sed '2d'
Any suggestions?
 
Old 01-22-2014, 03:41 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Try this? I think this is what you're trying to do:
Code:
SK1=`$skript | sed '1d'`
SK2=`$script | sed '2d'`
You can assign a variable to a command line sequence if you encase that command line sequence in back-single quotes. That's my experience, I'm not sure if this will work for you, but give it a try.
 
1 members found this post helpful.
Old 01-22-2014, 03:50 PM   #3
Osbian
LQ Newbie
 
Registered: Dec 2013
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thank you! I did manage to figure it out before you answered, and that is exactily how I did it. Very helpful!
 
  


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
[SOLVED] Bash script: How to assign variable to an sqlite3 command with variable embedded? ninja6o4 Linux - Software 10 02-15-2015 04:43 PM
[SOLVED] awk not working when setting command as variable keif Programming 8 05-07-2013 02:13 PM
[SOLVED] setting new variable to regex of another without changing the other variable in perl Eppo Programming 1 12-22-2011 02:35 PM
AWK a variable Ouptut to a new variable and using the new variable with the old one alertroshannow Linux - Newbie 4 02-16-2009 12:08 AM
setting a variable variable in a script... this works, but could it be more elegant? pwc101 Programming 3 08-18-2006 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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