set varibale to be output of a command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers set varibale to be output of a command
# 1  
Old 07-30-2012
set varibale to be output of a command

Hi there! Smilie
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 Smilie Smilie

Thanks in advance
# 2  
Old 07-30-2012
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%

This User Gave Thanks to Scott For This Post:
# 3  
Old 07-30-2012
Quote:
Originally Posted by Scott
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!!!! Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass IF condition via shell varibale in awk?

Hello, I have one query regarding passing IF condition shell variable inside awk. Here is the case- File content of keydefn.exp 201~2~LM Limit 02-current value~Limit 02 ~Limit02~Current~Value ~N~Y~S~0~9999999 201~3~LM Limit 03-current value~Limit... (2 Replies)
Discussion started by: anillambait
2 Replies

2. UNIX for Dummies Questions & Answers

Set Command to output a log of every command executed in the script

Hi Guys, I like to output every command executed in the script to a file. I have tried set -x which does the same. But it is not giving the logs of the child script which is being called from my script. Is there any parameters in the Set command or someother way where i can see the log... (2 Replies)
Discussion started by: mac4rfree
2 Replies

3. UNIX for Dummies Questions & Answers

set output delimiter as tab in cut command

I can not make it work, it prints \t rather than introduce tabs. cut -d "," -f 4,8 Samples.csv --output-delimiter="\t" | sort > out Since I am running this command within a shell script, I tried manually inserting tab in this command, still does not work. I am using bash shell Suggestions... (8 Replies)
Discussion started by: analyst
8 Replies

4. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

5. Shell Programming and Scripting

set variable to command output

I'm hoping you guys can help me out here. I've been trying different methods to try and get what IW as hoping would be a fairly simple script but has turned into a pain. Bit of background - I am writing a script to check values in certain failes to ensure they are corerct. I'm runnign this on... (2 Replies)
Discussion started by: stuc
2 Replies

6. Shell Programming and Scripting

Set specific part in command output into variable

I am trying unsuccessfully to set into a variable a specific part of command output: The command output will be as: line 1: <varied> line 2: 2 options: option 1: Set view: ** NONE ** or option 2: Set view: <different_name_of_views_always_without_spaces> and I would like to get into... (7 Replies)
Discussion started by: orit
7 Replies

7. Shell Programming and Scripting

How to use a varibale in sed

i wanna insert a row in a file. I m using this command to insert a row in the 13th line. sed '13i\ NewRow' MyFile > temp.txt mv temp.txt to MyFile this works fine. now i wanna get the line no using grep into a variable and then use tht variable to insert a new row.. how to do this wid... (8 Replies)
Discussion started by: St.Fartatric
8 Replies

8. Shell Programming and Scripting

passing of a varibale to subshell

Hi All, I need some info. Could you please tell me how to use the variable of a parent shell in the subshell. Also can we modify the variable in the subshell ? If yes, will the modified variable visible in the parent shell I am using two prg. a.sh #!/usr/bin/ksh temp_var="abhishek"... (3 Replies)
Discussion started by: AbhishekG
3 Replies

9. Shell Programming and Scripting

Varibale to NULL or ZERO

I have a variable called V_param1 and does it have some value. I want to check this varibale is NULL or Zero then exit else do How to incorported this in Script. any input (2 Replies)
Discussion started by: u263066
2 Replies

10. Shell Programming and Scripting

passing result of query to a varibale in ksh script

Hi, I have a scenario where in i have to extarct max of one column and pass it to a variable. i have tried to export the result as .dat file and read from that file.But my database is mainframe and it is not permitting me to export in .dat file.I have tried using .ixf file but reading from... (2 Replies)
Discussion started by: ammu
2 Replies
Login or Register to Ask a Question