Howdy

My name is Rowan Lewis, Im a web developer and standards enthusiast currently living on the Gold Coast, Australia where I work for a brilliant design and development firm known as R&B Creative Communication.

· bash · reference · scripting

Lets have a quick bash

I wrote a quick reference for doing common things in bash, particularly for those things that Im always forgetting.

Save the output of a command as a file:

$ ls *.txt > /path/to/file

Append the output of a command to a file:

$ echo 'Test.' >> /path/to/file

Get a list hidden files:

$ ls -A

Get a list only hidden files:

$ ls -d .??*

Get word count statistics:

$ wc -l < /path/to/file

Flags for wc:

l
Count lines
w
Count words
c
Count characters

Compress a directory:

$ tar -cj directory > archive.tar.bz2

Extract an archive:

$ tar -xj < archive.tar.bz2

Flags for tar:

j
Compress with bzip2 (.bz2)
z
Compress with gzip (.gz)
v
Show progress messages

Download a file over ftp or http:

$ wget http://domain/path/to/file
OR $ curl http://domain/path/to/file -o /path/to/output/file

Have your say

Comments can be formatted using a limited set of HTML elements;
a, code, em and strong.

Nobody has anything to say

Poor nobody, sitting here all alone, what would your mother think?  Be the first to leave a comment, or I tell your mum.