What's New!

Chat with
Hackers

How to Defend
Your Computer 

The Guides
to (mostly) 
Harmless Hacking

Happy Hacker 
Digests (old stuff) 

Hacker Links 

Hacker
Wargames 

Meet the 
Happy Hacksters 

Help for 
Beginners 

Hacker 
Bookstore 

Humor 

It Sucks 
to Be Me!

How to Commit
Computer Crime (not)! 

What Is a 
Hacker, Anyhow? 

Have a 
Great Life! 

News from the 
Hacker War Front


 The Bash Shell,continued...

   Tilde Expansion

    Another neat thing that bash provides is what is called Tilde Expansion. The tilde key (~) on it's own is expanded out to the user's home directory, for example. You can see this by issuing a 'cd ~' on your command line. Here is a list of expansions that bash will give you:

      ~     expands to $HOME
      ~bob  expands to bob's home directory
      ~+    $PWD
      ~-    $OLDPWD

   These expansions basically replace themselves on the command line with the contents of the second column above. Once the command has been expanded, bash executes it.

Aliases

    One of the things I could not do without is the alias command. If you enter any aliases, bash will fill out the text of the alias name with whatever the alias contents is before executing the command.

    For example, when I use ls, I like to see my directory listing in a certain way. Colors, for example, are good. I also like slashes (/) at the end of directory names just to show they are directories, and I also like to view all files starting with a full stop (.) in my listings.

   So instead of typing 'ls -Aop' every single time I want a dir listing, I just use an alias so that -Aop becomes my default. I enter the command:

alias ls='ls -Aop'

    And from then on, bash uses that alias as my default command. Whenever I enter the alias name (in this case 'ls'), bash expands that out to 'ls -Aop'automatically for me.

    If I want to remove the alias, I use 'unalias ls'. Alternatively, I can opt to type 'unalias -a' to remove all aliases I have set.

More on the bash shell --->>


Carolyn's most
popular book,
in 4th edition now!
For advanced
hacker studies,
read Carolyn's
Google Groups
Subscribe to Happy Hacker
Email:
Visit this group

 

Return to the index of Guides to (mostly) Harmless Hacking!

 © 2013 Happy Hacker All rights reserved.