LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-15-2009, 01:07 AM   #1
rajesh84210
Member
 
Registered: Jul 2009
Posts: 53

Rep: Reputation: 15
what does ~ symbol mean..


Dear All,
I would like to know the meaning or purpose of using "~" symbol in scripting language..The line is uri=~"sip:q@192.168.64.75"..
Thank you..
 
Old 09-15-2009, 01:13 AM   #2
mobinskariya
Member
 
Registered: Sep 2007
Location: Kerala, India
Distribution: ubuntu 10.04
Posts: 367

Rep: Reputation: 55
in scripting ~ normally represents your home directory.. may be it has got some other meaning.
try
Code:
cd ~
and you will understand.
 
Old 09-15-2009, 01:17 AM   #3
RaptorX
Member
 
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Rep: Reputation: 37
well the thing is that it has different meanings, one of them being what mobinskariya said but in this case I guess it is what the advance scripting guide calls:

=~

regular expression match. This operator was introduced with version 3 of Bash.

here two snipets where you can use this particular operator:

Quote:
#!/bin/bash

variable="This is a fine mess."

echo "$variable"

# Regex matching with =~ operator within [[ double brackets ]].
if [[ "$variable" =~ "T.........fin*es*" ]]
# ^ ^
# NOTE: Quoting not necessary, as of version 3.2 of Bash.
then
echo "match found"
# match found
fi
Or, more usefully:

Quote:
#!/bin/bash

input=$1


if [[ "$input" =~ "[1-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]" ]]
# ^ NOTE: Quoting not necessary, as of version 3.2 of Bash.
# NNN-NN-NNNN (where each N is a digit). Initial digit must not be 0.
then
echo "Social Security number."
# Process SSN.
else
echo "Not a Social Security number!"
# Or, ask for corrected input.
fi
here are all the meanings:

~

bitwise NOT

~

home directory [tilde]. This corresponds to the $HOME internal variable. ~bozo is bozo's home directory, and ls ~bozo lists the contents of it. ~/ is the current user's home directory, and ls ~/ lists the contents of it.

~+

current working directory. This corresponds to the $PWD internal variable.

~-

previous working directory. This corresponds to the $OLDPWD internal variable.

and

=~

regular expression match. This operator was introduced with version 3 of Bash.

Last edited by RaptorX; 09-15-2009 at 01:20 AM.
 
Old 09-15-2009, 01:20 AM   #4
rajesh84210
Member
 
Registered: Jul 2009
Posts: 53

Original Poster
Rep: Reputation: 15
i tried , but i do not get any message ... any ideas?
 
Old 09-15-2009, 01:23 AM   #5
RaptorX
Member
 
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Rep: Reputation: 37
Quote:
Originally Posted by rajesh84210 View Post
i tried , but i do not get any message ... any ideas?
if you are in your home directory ex. [~]
when you cd to ~ you will not see any change, because you are already there... try echo ~ instead.
 
Old 09-15-2009, 02:13 AM   #6
rajesh84210
Member
 
Registered: Jul 2009
Posts: 53

Original Poster
Rep: Reputation: 15
when i gave echo ~, i get /root .. thanks for ur time.. all i would like to know is what ~ means here.. uri=~ "sip:q@192.168.64.75"


Thanks in advance
 
Old 09-15-2009, 04:57 PM   #7
RaptorX
Member
 
Registered: Jun 2009
Location: Emden, Germany
Distribution: Slackware 12.2, Slax 6.1
Posts: 254

Rep: Reputation: 37
I thought the answer was in my first post.
If not Then I am not really sure what it is.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
symbol lookup error: /usr/lib/libavcodec.so.51: undefined symbol: av_crc04C11DB7 priceey Linux - Software 0 05-06-2009 09:14 AM
./firefox-bin :symbol lookup error:/lib/libgthread-2.0.so.0: undefined symbol: arulupsaras Linux - General 1 11-08-2008 05:48 AM
symbol lookup error: /usr/lib/libgtk-x11.2.0.so.0: undefined symbol:... IamI Slackware 17 02-29-2008 12:10 PM
Workaround: 'symbol lookup error: k3b: undefined symbol: lstat64' devdol Linux - Software 2 02-15-2008 04:36 AM
./firefox-bin: symbol lookup error: /usr/lib/libpango-1.0.so.0: undefined symbol: g_s cb8100 Slackware 3 10-05-2006 11:55 AM


All times are GMT -5. The time now is 09:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration