Results 1 to 3 of 3
Dear All,
Thanks for reading my thread. My problem is the following:
I have a command, for example, mycommand. After running this command one has as string like 'my string'. ...
- 10-23-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 2
[SOLVED] How to assign a variable in csh shell for this specific situation?
Dear All,
Thanks for reading my thread. My problem is the following:
I have a command, for example, mycommand. After running this command one has as string like 'my string'. 'my string' depends on some variables so that it is not a constant.
Now I want to assign myvar = 'my string', how do I do that?
what I tried is:
1/
(echo -n set myvar =; mycommand)>out
eval out
echo $myvar
2/
(echo -n set myvar =; mycommand)>out
chmod +x out
./out
echo $myvar
but both of them do not work.
Could you please help me with this problem?
Thank you in advance.
N
- 10-24-2009 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
The special quote mark, " ` ", also called a backtic can be used. On many keyboards it is found upper left, on the same key as the tilde, " ~ ". One uses it in both sh and csh families to run a command and substitute the output:
producing:Code:#!/usr/bin/env tcsh # @(#) s1 Demonstrate setting variable to output from command. echo setenv LC_ALL C ; setenv LANG C echo "Environment: LC_ALL = $LC_ALL, LANG = $LANG" echo "(Versions displayed with local utility version)" sh -c "version >/dev/null 2>&1" && version "=o" tcsh echo set myvar = `date` echo " date is $myvar" exit 0
See man csh. Best wishes ... cheers, drlCode:% ./s1 Environment: LC_ALL = C, LANG = C (Versions displayed with local utility version) OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64 Distribution : Debian GNU/Linux 5.0 tcsh 6.14.00 date is Sat Oct 24 05:43:52 CDT 2009
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 10-24-2009 #3Just Joined!
- Join Date
- Oct 2009
- Posts
- 2



