Useful commands

By | 2011/07/25

Counting the number of words in file:

cat file.txt | wc -w

Searching the output for “uzza” word:

cat big-file.txt | grep uzza

Gzipping files:

gzip some_file.txt

Decompressing Gzipped files:

gzip -d some_file.txt.gz

Creating archive of directory:

tar -cvf archive-name.tar some-dir

c – creating new archive
v – verbose
f – we want to specify the name of the output file

Creating compressed archive of directory:

tar -czvf archive-name.tgz some-dir

z – compress with gzip

Expending the archive:

tar -xzvf archive-name.tgz

x – tells to expend rather than compress

Creating entire directory structure:

mkdir -p dir1/dir2/dir3