less typing History history lists recent commands number
less typing History history lists recent commands. !<number> redoes that command !<partial> redoes the most recent command that started with <partial> letters Globbing Describe to the shell (not OS) sets of file names with patterns ~ means the home directory ? means any character * means any string (including empty) [<letters>] means any one of the <letters> (except. . . ), which can also be a range ^ negates some glob expressions File name completion Many shells provide file name completion: Use tab key to expand partial file names
locate a file locate unix_class_files. zip locate the path for file unix_class_files. zip locate unix_class locate the path for all the files containing unix_class
grouping & compressing files groups and compresses files tar –czvf file. tar. gz file 1 file 2 tar –xzvf file. tar. gz ungroups and decompresses file. tar. gz
grouping & compressing files gzip file 1 compresses file 1 into file. gz zip file. zip f 1 f 2 compresses f 1 and f 2 into file. zip unzip file. zip decompresses file. zip gunzip file. gz decompresses file. gz
Text handling commands
cat, less cat file 1 displays file 1 as a whole cat file 1 file 2 file 3 concatenates and displays file 1, file 2 and file 3 as a whole cat file 1 file 2 file 3 > out. txt cat file 4 file 5 >> out. txt less file 1 < or g > or G space b concatenates file 1, file 2 and file 3 and redirects output to file out. txt concatenates file 4 and file 5 and appends output to file out. txt displays file 1 page-by-page allows scrolling through the file goes to the beginning goes to the end page down page up /pattern search pattern n find next one N find previous q quit
head, tail head file 1 displays the first 10 lines of file 1 head –n 20 file 1 tail file 1 displays the first 20 lines of file 1 displays the last 10 lines of file 1 tail –n 20 file 1 displays the last 20 lines of file 1
regular expressions - grep Regular expressions describe sets of strings with patterns (not the same as globbing) • A normal character matches itself • . matches any normal character • A range [<letters>] matches any one of the <letters>, which can also be a range [^<letters>] matches any not one of the <letters> • ? after a pattern makes it optional • + after a pattern matches one or more repetitions • * after a pattern matches any number of repetitions • {<N>} after a pattern matches <N> repetitions in regular expressions • ^ means the start of the line • $ means the end of the line • ()s round a regular expression makes it one thing to which repetition and placement options can be applied. • grep finds lines in files that match limited regular expressions. grep ‘^>’ file. txt displays lines in file. txt that start with a > grep -c ‘^+$’ *fastq displays lines in all fasta files that are composed of a single +
- Slides: 8