variable to string
Hi ! All
Trying to pick up shell script. When I do : mis="123" echo $mis It return "123" Now, if I want to return the the result "mis" instead of value "123". How can I do that ? I am beginner, appreciate all the experts here to help. Regards, x2000koh |
Simple: you have to escape (take away special meaning) the quotes.
XXX=\"xxx\" echo $XXX Gives "xxx" You may also use single quotes. Everything inside is taken literally, without any special meaning, ie XXX=' "xxx" ' If you want to surround text with single quotes, you have to use the backslash escape method. Recommended reading: bash(1) # that is the man page in section 1. Try man bash bash info documentation Advanced Bash Scripting HOWTO (start out simple. See www.tldp.org) |
Re: variable to string
Quote:
Code:
echo mis |
strike
Thanks for reply ! to let you know the full picture of what I am going to do. 1) I have written a script to evaluate the user group (GID). It only return the GID in number. But I want it to return a group name. My script is as follow. addlink.sh ------------- group=$(id -g) echo $group when I run the above it return "511". let say GID 511 is mis group. How can I convert the 511 to show mis. (can I echo $511 ?) 2) softlink base on department if GID is mis ln -s /home/dept/mis mis end if 3) calling a script How can I call another script from my existing program ? Which command to use ? I want the .bash_profile to call the addlink.sh when user login. The addlink.sh is located at /home/maple The .bash_profile is located at /home/maple/$USER appreciate your help. x2000koh |
To lookup a group, based on numwerical GID, use id -gn. (or grep if youre feeling masochistic)
To call another script, see my reply in the other thread you started |
All times are GMT -5. The time now is 04:17 PM. |