Sponsored by Dragon Age: Origins
Join the Dragon Age: Origins development team on Facebook view!
facebook.com/DragonAgeOrigins - EA presents BioWare's new dark fantasy epic Dragon Age: Origins. '9/10' from Game Informer.
42 Comments
- coit, on 10/11/2007, -3/+14master what?? boy, I sure read that wrong the first time!
- n5yat, on 10/11/2007, -4/+13Should be re-titled "10 shortcuts to master bash that everyone else except the author already knew..."
- Dankoozy, on 10/11/2007, -0/+9I knew most of these already except for doing calculations i would normally use Python.
Here's another good one from the kind folk at IBM, which has been on Digg quite a few times now I think
http://www.ibm.com/developerworks/aix/library/au-badunixhabits.html - meerkat, on 10/11/2007, -0/+7Definitely not for a master in training... good for a beginner though.
- friedcalamari, on 10/11/2007, -0/+6"I hate bash because it made me type man mount"
- crash128, on 10/11/2007, -1/+7they did the bash,
they did the master bash,
it was a smash,
it was a command-line smash.... - gann, on 10/11/2007, -0/+6look; find; talk; grep; touch; finger; find; flex; unzip; mount; workbone; fsck; yes; gasp; fsck; yes; eject; umount; makeclean; zip; split
- minastirth, on 10/11/2007, -0/+5>10 shortcuts to master bash
"master" is not the right word here. You can't master bash with just 10 basics. The title should be more like "Another bash tutorial". No one will digg it then, because it does not deserve to be. - bigwyrm, on 10/11/2007, -0/+5look (1) - display lines beginning with a given string
find (1) - search for files in a directory hierarchy
talk (1) - talk to another user
grep (1) - print lines matching a pattern
touch (1) - change file timestamps
finger (1) - user information lookup program
flex (1) - fast lexical analyzer generator
unzip (1) - list, test and extract compressed files in a ZIP archive
mount (8) - mount a file system
workbone - Text-mode CD player (no longer common)
fsck (8) - check and repair a Linux file system
yes (1) - output a string repeatedly until killed
gasp (1) - the GNU Assembler Macro Preprocessor
eject (1) - eject removable media
umount (8) - unmount file systems
make clean - Good job. You spotted one that was wrong.
zip (1) - package and compress (archive) files
split (1) - split a file into pieces
Nice try, anyway. - funkytaco, on 10/11/2007, -0/+4I prefer to use this alias instead of plain ls:
alias ll='ls -lah'
And one nobody seems to know:
!ping
That will ping the last site you pinged. Use ! with any command in your command history to reuse it.
!78
Will execute the 78th command in your bash history. - asauterChicago, on 10/11/2007, -0/+4I master-bash like three times a day.
- angrykeyboarder, on 10/11/2007, -0/+2actually...
it's more like
$ su -c 'rm -rf /'
OR
$ sudo rm -rf /
Just to be "safe" ;) - angrykeyboarder, on 10/11/2007, -0/+2"Master" is a stretch for this article. But I did learn a few tings, although I've noted some of it is old/wrong.
Frankly if you want to "master" bash via teh Internets, I recommend:
www.linuxcommand.org - phjr, on 10/11/2007, -0/+2Yeah, nothing extraordinary. But CDPATH is quite nice.
- jgerry, on 10/11/2007, -0/+2Some of the other non-bash shells won't work with the abbreviated "export XYZ=A" syntax. It's generally good practice to use the old syntax -- especially in a shared environment where multiple sysadmins will have to work on the same server. They may not use bash as their shell of choice.
It's an easy thing to do that has saved me countless hours trying to debug someone else's shell scripts. - PolarPyro, on 10/11/2007, -2/+4i thought it said monster mash -_-
- inactive, on 10/11/2007, -0/+2I read it as "Monster Bash" That game was the first PC gamed I brought. Went around with a slingshot freeing puppies and avoiding skulls.
- speaker219, on 10/11/2007, -1/+2http://en.wikipedia.org/wiki/Bash
- phjr, on 10/11/2007, -0/+1I would agree. Python is just easier for doing calculations. Not 2+2, but some more complex are really easier and more intuitive (and also more reliable) to do in Python (or Ruby, or maybe Perl).
- speaker219, on 10/11/2007, -0/+1back to reality
it does have "master" in the title, and it is being dugg. - nailer, on 10/11/2007, -1/+2really?
I'm surprised he bothered with the old...
VARIABLE=value
export VARIABLE
When ...
export VARIABLE=value
would have sufficed. - crash128, on 10/11/2007, -0/+1That right there - I don't care who your are - that was funny. Golf clap.
- Stonekeeper, on 10/11/2007, -0/+1python is great not only for doing calculations, but for doing things based on the outputs of other commands. I regularly use popen() in my own scripts to monitor command output and to do things accordingly. Python is just fantastic for scripting.
- bigwyrm, on 10/11/2007, -0/+1OMG! I remember that one. I think I may still have it around here on 5.25 in floppy somewhere.
- angrykeyboarder, on 10/11/2007, -0/+1I guess I should have put the Stallman part earlier in the "lyrics"....
- yomomo, on 10/11/2007, -0/+1thats better than 10 shortcuts to master bating.
- licoricewhip, on 10/11/2007, -0/+1If only this was an article about fishing...
- gabbagabbahey, on 10/11/2007, -0/+1You should always specify the shell in the script to avoid issues like this (#!/bin/sh on the first line.)
- icoms, on 10/11/2007, -2/+2this one is missing: rm -rf /
- Vengefultacos, on 10/11/2007, -0/+0Whoa, did I misinterpret the title of this post. At first I thought it was offering quick ways to get to some sort of party (perhaps held by BDSM tops). Then I thought it might refer a few cheats that let you get through to some boss named "Master Bash" in some beat 'em up arcade game....
And the funny part is I have a BASH shell open in the next window over. - erlkonig, on 10/11/2007, -1/+1A very typical Bash article.
(2) Recommending aliases is pretty strange advice. Aliases in bash are quite odd, especially if the trailing character is a space (see the manual page), and deprecated even by the manual page. I usually disable aliases to avoid having my command set meddled with by the less-bright /etc/profile.d script some packages come with. The modern way is to use functions, like this shortcut for listing called "l" (ell):
l () { ls -FCas "$@"; }
Fully consistent with Bourne syntax, formats nicely with typeset or set, and lets you expand it to have things AFTER the arguments, like this (admittedly contrived):
l () { ls -FCas "$@" ; echo done; }
(3) Programmable completion is awesome. Like:
complete -A directory rmdir
complete -f -o default -X '!*.pdf' acroread # or evince, or xpdf, or whatever
complete -f -o default -X '!*.ps' ghostview gv
complete -f -o default -X '!*.gz' gunzip
Open a command with rmdir, acroread, ghostview, or gunzip (for which you might have already used command completion to avoid typing), and then another tab give you the right kind of filenames. Lovely.
Or you can get hostname completion with SSH for your common SSH targets for any command starting with ssh or scp:
_complete_ssh ()
{
local ssharg="${COMP_WORDS[COMP_CWORD]}"
local filter=cat
case "$ssharg" in *@*) filter="sed s/^/${ssharg%@*}@/" ;; esac
local host=${ssharg##*@}
COMPREPLY=( $(compgen -W "`
sed 's/[, ].*//' ~/.ssh*/known_hosts{,2} | sort | uniq
`" $host | $filter ))
return 0
}
complete -F _complete_ssh ssh
# This version of scp forces the use of M-/ to see filenames instead of hosts.
complete -F _complete_ssh -o nospace -S : scp
(5) MAILPATH for email autonotify only works in simple cases - a large number of folks read email exclusively via POP, IMAP, or a web client nowadays.
(6) Foregrounding - I like just using "%1" to foreground job 1.
(7) It's weird to see the CDPATH exported with the old Bourne shell syntax when the value being exported (the "~") will only work in Bash :-) - BlackAle, on 10/11/2007, -1/+1bash what?
http://dictionary.reference.com/browse/bash - schestowitz, on 10/11/2007, -4/+4This seems like a set of rather arbitrary (but useful) examples. Nothing out of the ordinary. There are entire books (some online) that serve as step-by-step tutorials that's cumulative.
- inactive, on 10/11/2007, -6/+6One of the best guides for bash i have ever read.
- mountaincable, on 10/11/2007, -1/+1Psst, that is an alias in itself. Some distros are just more accomodating out of the box.
- obsaysditto, on 10/11/2007, -1/+1the bash man pages... frequently used.
http://www.ss64.com/bash/ - GaryS278, on 10/11/2007, -2/+1fail, it's "make clean". half of these aren't commands anyways
- angrykeyboarder, on 10/11/2007, -3/+2Some have made this um "point" but I thought I'd elaborate...
I was working in the lab late one night
When my eyes beheld an eerie sight
For my master from his slab began to rise
And suddenly to my surprise
He mastered bash
He did the master bash
The master bash
It was a graveyard smash
He mastered bash
It caught on in a flash
He mastered bash
He did the master bash
From my laboratory in the castle east
To the master bedroom where the vampires feast
The ghouls all came from their humble abodes
To get a jolt from my electrodes
They mastered bash
They did the master bash
The master bash
It was a graveyard sbash
They did the bash
It caught on in a flash
They did the bash
They did the master bash
The zombies were having fun
The party had just begun
The guests included Stallman
Dracula and his son
The scene was rockin', all were digging the sounds
Stallman on chains, backed by his baying hounds
The coffin-bangers were about to arrive
With their vocal group, "The Crypt-Kicker Five"
They mastered bash
They played the master bash
They mastered bash
It was a graveyard sbash
They mastered bash
It caught on in a flash
They mastered bash
They played the master bash
Out from his coffin, Drac's voice did ring
Seems he was troubled by just one thing
He opened the lid and shook his fist
And said, "Whatever happened to my Transylvania twist?"
It's GNU bash
It's now GNU bash
The GNU bash
And it's a graveyard sbash
It's GNU bash
It's caught on in a flash
It's now the bash
It's now the master bash
Now everything's cool, Stallman's a part of the band
And my master bash is the hit of the land
For you, the living, GNU bash was meant too
When you get to my door, tell them Boris sent you
Then you can bash
Then you can master bash
The GNU bash
And do my graveyard sbash
Then you can bash
You'll catch on in a flash
Then you can bash
Then you can master mash - marcus553, on 10/11/2007, -2/+1I hope I hear sarcasm in your text. This page contains a few basic tips for those new to bash, but it certainly doesn't help you "master bash".
WT? image captcha shows one thing, audio says another, ans neither work?? Reloading to try again... - techfish, on 10/11/2007, -4/+2bash> alias ls='ls -l'
or just use ll (distro specific i think) - phlogiston99, on 10/11/2007, -4/+110 shortcut to bash master.
This commenting system is still retarded. - GaryS278, on 10/11/2007, -4/+0ll was on my BSD but not Gentoo. BSD was csh though, not bash.


What is Digg?