Show Menu
Cheatography

COMP 206 Final Cheat Sheet (DRAFT) by

Crib sheet of bash and C commands

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Basic Bash commands

pwd
print working directory
touch
create file
cat
display file
>
redirect output to file
>>
append output to file
|
pipe to another command
diff file1 file2
compare two files
ln / ln -s
create hard (alt name) / symbolic (new file that auto-r­edi­rects) link
sort file
sort lines
wc file
word count
cp, mv, and rm options: -i confir­mation prompt; -f force, -r recurs­ively visit subdir­ect­ories

Wildcards

*
any pattern
?
any single character
[xyz] / [x-z]
any of these / any within the range
Globbing: Shell interprets wildcards as the list of all matching pathnames

regex

grep 'STRING' FILE_LIST
finds occurr­ences of STRING within FILE_LIST
-i
ignore case
-c
return only count: # of matching lines
-v
inverted search (return only non-ma­tches)
-n
display line number with matching line
-l
list only file names

Archiving

tar -
combine several files into one
-c
create new tar archive
-r
update tar archive
-x
extract from tar archive
-f
specify archive file name
-v
verbose mode
-z
compress archive w gzip
gzip
compress a single file
A regular tar archive file ends with .tar; a gzipped tar archive file ends with .tgz