Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-30-2012
Registered User
 
Join Date: Apr 2012
Posts: 33
Thanks: 28
Thanked 0 Times in 0 Posts
set varibale to be output of a command

Hi there!
How to set varibale to be output of a command in csh.
I was using
Code:
set i="date+'%y%m%d'"

but the output is date+'%y%m%d' and without quites and with a single quote the output is the same

Thanks in advance
Sponsored Links
    #2  
Old 07-30-2012
Scott's Avatar
Scott Scott is online now Forum Staff  
Administrator
 
Join Date: Jun 2009
Location: Zürich
Posts: 6,950
Thanks: 220
Thanked 760 Times in 664 Posts
Hi.

Use back-quotes.

i.e.

Code:
[Scotts-MBP:~] scott% echo $0
csh
[Scotts-MBP:~] scott% set X=`date '+%y'`
[Scotts-MBP:~] scott% echo $X
12
[Scotts-MBP:~] scott%

The Following User Says Thank You to Scott For This Useful Post:
FUTURE_EINSTEIN (07-30-2012)
Sponsored Links
    #3  
Old 07-30-2012
Registered User
 
Join Date: Apr 2012
Posts: 33
Thanks: 28
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Scott View Post
Hi.

Use back-quotes.

i.e.

Code:
[Scotts-MBP:~] scott% echo $0
csh
[Scotts-MBP:~] scott% set X=`date '+%y'`
[Scotts-MBP:~] scott% echo $X
12
[Scotts-MBP:~] scott%

Thanks a lot this works!!!!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Command display output on console and simultaneously save the command and its output satimis UNIX for Dummies Questions & Answers 7 01-25-2009 07:27 PM
How to use a varibale in sed St.Fartatric Shell Programming and Scripting 8 05-30-2008 03:04 AM
passing of a varibale to subshell AbhishekG Shell Programming and Scripting 3 05-25-2008 09:49 AM
Varibale to NULL or ZERO u263066 Shell Programming and Scripting 2 09-06-2006 07:12 AM
passing result of query to a varibale in ksh script ammu Shell Programming and Scripting 2 07-27-2006 01:05 AM



All times are GMT -4. The time now is 11:34 PM.