LinuxQuestions.org
Visit Jeremy's Blog.
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 01-17-2006, 12:22 AM   #1
Karthikeyan Gurusamy
LQ Newbie
 
Registered: Dec 2005
Posts: 14

Rep: Reputation: 0
tilde symbol for what purpose


Hi All,

Can anybody pl. tell me, if tilde symbol displays at linux prompt, what does it mean?
Is it default symbol of any shell?

regards,

karthik
 
Old 01-17-2006, 12:38 AM   #2
T.Hsu
Member
 
Registered: Jan 2005
Posts: 178

Rep: Reputation: 31
Quote:
Tilde Expansion


If a word begins with an unquoted tilde character (`~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as a possible login name. If this login name is the null string, the tilde is replaced with the value of the shell parameter HOME. If HOME is unset, the home directory of the user executing the shell is substituted instead. Otherwise, the tilde-prefix is replaced with the home directory associated with the specified login name.

If the tilde-prefix is a `~+', the value of the shell variable PWD replaces the tilde-prefix. If the tilde-prefix is a `~-', the value of the shell variable OLDPWD, if it is set, is substituted. If the characters following the tilde in the tilde-prefix consist of a number N, optionally prefixed by a `+' or a `-', the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the dirs builtin invoked with the tilde-prefix as an argument. If the characters following the tilde in the tilde-prefix consist of a number without a leading `+' or `-', `+' is assumed.

If the login name is invalid, or the tilde expansion fails, the word is unchanged.

Each variable assignment is checked for unquoted tilde-prefixes immediately following a : or the first =. In these cases, tilde expansion is also performed. Consequently, one may use file names with tildes in assignments to PATH, MAILPATH, and CDPATH, and the shell assigns the expanded value.
from bash manpage, also

Quote:
PROMPTING
When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command. Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:


\a
an ASCII bell character (07)
\d
the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format}
the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
\e
an ASCII escape character (033)
\h
the hostname up to the first `.'
\H
the hostname
\j
the number of jobs currently managed by the shell
\l
the basename of the shell's terminal device name
\n
newline
\r
carriage return
\s
the name of the shell, the basename of $0 (the portion following the final slash)
\t
the current time in 24-hour HH:MM:SS format
\T
the current time in 12-hour HH:MM:SS format
\@
the current time in 12-hour am/pm format
\A
the current time in 24-hour HH:MM format
\u
the username of the current user
\v
the version of bash (e.g., 2.00)
\V
the release of bash, version + patch level (e.g., 2.00.0)
\w
the current working directory, with $HOME abbreviated with a tilde
\W
the basename of the current working directory, with $HOME abbreviated with a tilde
\!
the history number of this command
\#
the command number of this command
\$
if the effective UID is 0, a #, otherwise a $
\nnn
the character corresponding to the octal number nnn
\\
a backslash
\[
begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
\]
end a sequence of non-printing characters
hope these answer your question, and "man" is your true friend.

Last edited by T.Hsu; 01-17-2006 at 12:39 AM.
 
Old 01-17-2006, 12:41 AM   #3
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
The ~ character is normally a shortcut to your home directory. You can use it instead of typing /home/karthik in a shell.

EG:
cd ~ will take you to your home directory
ls ~/bin will list the contents of the bin directory in your home.

--Ian
 
Old 01-17-2006, 01:27 AM   #4
Karthikeyan Gurusamy
LQ Newbie
 
Registered: Dec 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks a lot

Thanks a lot friends!!!!

regards,

karthik
 
Old 01-17-2006, 05:22 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
IBall, in most shells, you can go even one step further:
~ian/ represents the home directory of user "ian", for example.
 
  


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
Lost my tilde key ( ~ ) nakko Debian 5 09-12-2006 10:27 AM
Tilde name shortening steveel Slackware 6 11-21-2005 04:55 AM
purpose of symbol ^ sharonyiisl Linux - Newbie 3 09-20-2004 02:14 PM
tilde in X nva Linux - General 2 06-30-2003 12:12 PM
Filenames with tilde rovoreed Programming 2 08-08-2001 05:53 PM


All times are GMT -5. The time now is 02:35 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration