| layout | reference |
|---|---|
| title | Reference |
| permalink | /reference/ |
pwd print working directory
ls list directory
-l: list file information-lh: list human readable file information
cd change directory
mkdir make directory
cat send file or files to output (in most cases, print to shell)
head output first 10 lines of a file or files
tail output last 10 lines of a file or files
mv rename or move a file or files. Syntax for renaming a file: mv FILENAME NEWFILENAME
cp copy a file or files. Syntax: cp FILENAME NEWFILENAME
> redirect output. Syntax with cat: cat FILENAME1 FILENAME2 > NEWFILENAME
rm remove a file or files. NB: USE WITH EXTREME CAUTION!!!
? a placeholder for one character or number
* a placeholder for zero or more characters or numbers
[] defines a class of characters
Examples
foobar?: matches seven character strings starting withfoobarand ending with one character or numberfoobar*: matches strings starting withfoobarending with zero or more further characters or numbersfoobar*txt: matches strings starting withfoobarand ending withtxt[1-9]foobar?: matches eight character strings starting that start with a number, havefoobarafter the number, and end with any character or number.
wc word count
-w: count words-l: count lines-c: count characters
sort sort input
grep global regular expression print
-c: displays counts of matches for each file-i: match with case insensitivity-w: match whole words-v: exclude match--file=FILENAME.txt: use the fileFILENAME.txtas the source of strings used in query**|**: (vertical bar character) send output from one command into another comma