Basic doubt in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Basic doubt in UNIX
# 1  
Old 04-18-2013
Basic doubt in UNIX

Hi,

I'm new to this and very much interested to learn unix.
Can any one explain me the symbols y we use this is scripting(~ and $).
It would be great if some one explain with the eg.

Thanks
Naveen A
# 2  
Old 04-18-2013
$ is used to access (read) a variable. Whenever you see $ symbol, whatever follows is a shell variable.

So look at the following:
Code:
x=12 # assigns value of 12 to the variable "x"
echo $x # reads variable "x", gets value of 12, echo command prints 12

Alternatively, you can say ${x} which is exactly the same. This can be used to prevent the letter x from "running into" other following text.

Of course, when you are using UNIX at the command line, $ is the typical command prompt.
# 3  
Old 04-18-2013
Quote:
Originally Posted by Pranaveen
Hi,

I'm new to this and very much interested to learn unix.
Can any one explain me the symbols y we use this is scripting(~ and $).
It would be great if some one explain with the eg.

Thanks
Naveen A
Naveen,
I think hanson44 pretty well described many of the uses of $. The $ is also used to represent the end of a string in a regular expression and can actually be used to represent the dollar sign symbol in a string (depending on context and they types of quotes used to delimit the string).

The ~ is used to represent a user's home directory when it is unquoted at the start of a pathname. It can be used by itself to represent the home directory of the user who is currently logged in (such as vi ~/.profile to edit a file named .profile in your home directory) or with a user's name to represent that user's home directory (such as vi ~dwc/.profile to try to edit the file named .profile in my home directory).

Last edited by Don Cragun; 04-18-2013 at 02:30 AM.. Reason: add missing closing square bracket
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Doubt in Unix ??

Is it possible to create unix or linux commands ? if it is then how to create ?:) (1 Reply)
Discussion started by: Santhosh Raju
1 Replies

2. UNIX for Dummies Questions & Answers

sed basic doubt

Hi , what is the equivalent of below awk in sed. awk '$1=="ABC"&&$2=="XYZ" {print $0}' infile Thanks, Shruthi (6 Replies)
Discussion started by: shruthidwh
6 Replies

3. Shell Programming and Scripting

shell script basic doubt

hi, I am new script learner, so my basic doubt is , how to store value of any command in a variable example $ ls | wc -l i want to stote the output of this in a variable c. so that i can use c in if else loop. and when do we use " ` " symbol in script.. can anyone also tell for... (5 Replies)
Discussion started by: hi2_t
5 Replies

4. Shell Programming and Scripting

Basic SED doubt

Hi Friends!! I want to add a / at the end of a number. for example i have CQ65758 /, in this case i want to shift that backspace one space to the left so the my result becomes CQ65758/. How can i do that with sed. Thanks Adi (3 Replies)
Discussion started by: asirohi
3 Replies

5. UNIX for Advanced & Expert Users

Unix Doubt

What is Primary Group & Secondary group and what is the difference between them. (5 Replies)
Discussion started by: harishankar
5 Replies

6. UNIX for Dummies Questions & Answers

got a basic doubt on cat-file permissions

Hi all, Today I was just fooling around with directories and faced this. I create a directory 'testdir' and create a file 'myfile' inside it. gandalf@gondor:~$ mkdir testdir gandalf@gondor:~$ cd testdir gandalf@gondor:~/testdir$ touch myfile Then I set the following permissions for the... (7 Replies)
Discussion started by: ranj@chn
7 Replies

7. UNIX for Dummies Questions & Answers

Unix basic help

What command would I use to list the first lines of all text files within my Unix directory or within any directory inside there? I was using "find" , "head" and "-exec" commands like this: find ~/Unix -name "*.txt" -exec head {} \; But its not perfectly working, please help me.... (2 Replies)
Discussion started by: carrera911
2 Replies

8. Shell Programming and Scripting

Shell scripting basic doubt

Hi, I have a script called sam.sh which consists of a single echo statement like this #/usr/bin/ksh echo "Mani" I changed the mode for the script by giving chmod a+x sam.sh. If I want to execute the scrpt by just giving the name at the command line "sam.sh", what should I necessarily do?... (3 Replies)
Discussion started by: sendhilmani123
3 Replies

9. Shell Programming and Scripting

Certainly basic doubt about IF

On the below "IF" i test if the user have put the first argument. I also would like to test if the user have written a second argument. So, my doubt is: - How can i evaluate 2 conditions on a if statement? How is the OR created? - How can i to verify if the second argument is non... (1 Reply)
Discussion started by: tmxps
1 Replies

10. UNIX for Dummies Questions & Answers

Basic unix

okay, im having some trouble. Go ahead, call me a retard, but i keep getting stuck. Suppose i want to open a Picture of Jesus(for the sake of simplicity) using unix. I type: open Desktop/Pictures/Jesus.jpg It opens, and its all well and good. But, suppose i want to open a picture called Joe... (4 Replies)
Discussion started by: HipCracka
4 Replies
Login or Register to Ask a Question