LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-13-2008, 06:05 PM   #1
MrFixit
Member
 
Registered: Aug 2004
Posts: 32

Rep: Reputation: 15
inserting program output into a variable


Hello,
I know that with C Shell i can do this:

set var1=`some_command with_arguments`
and get in var1 the output of that command with these arguments...

is there a way to achieve this in Dash and Bash?

Last edited by MrFixit; 03-13-2008 at 06:19 PM.
 
Old 03-13-2008, 06:28 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603
Skip the "set " part?
 
Old 03-13-2008, 06:42 PM   #3
MrFixit
Member
 
Registered: Aug 2004
Posts: 32

Original Poster
Rep: Reputation: 15
heh, sorry...
I had to use `./executable_name arguments` instead of `executable_name arguments`

now its fine, silly me...
 
Old 03-13-2008, 06:48 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 67
You can use either of these:
Code:
variablename=`some command`
variablename=$(some command)
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
capture the output to a variable Melsync Linux - General 4 09-07-2006 03:17 PM
How to direct screen output to a variable? vimal Programming 6 08-29-2006 01:06 AM
how to save output from a command to a variable? tomolesonjr Linux - Newbie 6 04-19-2006 04:04 PM
in C, Assigning output of system() to a variable Miaire Programming 4 01-30-2005 01:40 PM
insert output of sed into a variable hwouters Linux - General 3 11-06-2004 08:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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