diff --git a/README.md b/README.md index 27afa2f..3e7bd20 100644 --- a/README.md +++ b/README.md @@ -3,30 +3,30 @@
## Table of Contents - 1. [Basic Operations](#1-basic-operations) - 1.1. [File Operations](#11-file-operations) - 1.2. [Text Operations](#12-text-operations) - 1.3. [Directory Operations](#13-directory-operations) - 1.4. [SSH, System Info & Network Operations](#14-ssh-system-info--network-operations) + 1. [Basic Operations](#1-basic-operations) + 1.1. [File Operations](#11-file-operations) + 1.2. [Text Operations](#12-text-operations) + 1.3. [Directory Operations](#13-directory-operations) + 1.4. [SSH, System Info & Network Operations](#14-ssh-system-info--network-operations) 1.5. [Process Monitoring Operations](#15-process-monitoring-operations) - 2. [Basic Shell Programming](#2-basic-shell-programming) - 2.1. [Variables](#21-variables) - 2.2. [Array](#22-array) - 2.3. [String Substitution](#23-string-substitution) - 2.4. [Other String Tricks](#24-other-string-tricks) - 2.5. [Functions](#25-functions) - 2.6. [Conditionals](#26-conditionals) - 2.7. [Loops](#27-loops) - 2.8. [Regex](#28-regex) - 2.9. [Pipes](#29-pipes) - 3. [Tricks](#3-tricks) - 4. [Debugging](#4-debugging) + 2. [Basic Shell Programming](#2-basic-shell-programming) + 2.1. [Variables](#21-variables) + 2.2. [Array](#22-array) + 2.3. [String Substitution](#23-string-substitution) + 2.4. [Other String Tricks](#24-other-string-tricks) + 2.5. [Functions](#25-functions) + 2.6. [Conditionals](#26-conditionals) + 2.7. [Loops](#27-loops) + 2.8. [Regex](#28-regex) + 2.9. [Pipes](#29-pipes) + 3. [Tricks](#3-tricks) + 4. [Debugging](#4-debugging) 5. [Multi-threading](#5-multi-threading) # 1. Basic Operations ### a. `export` -Displays all environment variables. If you want to get details of a specific variable, use `echo $VARIABLE_NAME`. +Displays all environment variables. If you want to get details of a specific variable, use `echo $VARIABLE_NAME`. ```bash export ``` @@ -67,7 +67,7 @@ $ whereis php ### d. `which` which searches for executables in the directories specified by the environment variable PATH. This command will print the full path of the executable(s). ```bash -which program_name +which program_name ``` Example: ```bash @@ -108,14 +108,14 @@ Clears content on window. ### a. `cat` -It can be used for the following purposes under UNIX or Linux. +It can be used for the following purposes under UNIX or Linux. * Display text files on screen -* Copy text files -* Combine text files -* Create new text files +* Copy text files +* Combine text files +* Create new text files ```bash cat filename -cat file1 file2 +cat file1 file2 cat file1 file2 > newcombinedfile cat < file1 > file2 #copy file1 to file2 ``` @@ -133,20 +133,20 @@ chown -options user:group filename ``` ### d. `cp` -Copies a file from one location to other. +Copies a file from one location to other. ```bash cp filename1 filename2 ``` Where `filename1` is the source path to the file and `filename2` is the destination path to the file. ### e. `diff` -Compares files, and lists their differences. +Compares files, and lists their differences. ```bash diff filename1 filename2 ``` ### f. `file` -Determine file type. +Determine file type. ```bash file filename ``` @@ -167,37 +167,37 @@ $ find /home/user1 -name '*.png' ``` ### h. `gunzip` -Un-compresses files compressed by gzip. +Un-compresses files compressed by gzip. ```bash gunzip filename ``` ### i. `gzcat` -Lets you look at gzipped file without actually having to gunzip it. +Lets you look at gzipped file without actually having to gunzip it. ```bash gzcat filename ``` ### j. `gzip` -Compresses files. +Compresses files. ```bash gzip filename ``` ### k. `head` -Outputs the first 10 lines of file +Outputs the first 10 lines of file ```bash head filename ``` ### l. `less` -Shows the contents of a file or a command output, one page at a time. It is similar to [more](#q-more), but has more advanced features and allows you to navigate both forward and backward through the file. +Shows the contents of a file or a command output, one page at a time. It is similar to [more](#q-more), but has more advanced features and allows you to navigate both forward and backward through the file. ```bash less filename ``` ### m. `lpq` -Check out the printer queue. +Check out the printer queue. ```bash lpq ``` @@ -210,19 +210,19 @@ active adnanad 59 demo 399360 bytes ``` ### n. `lpr` -Print the file. +Print the file. ```bash lpr filename ``` ### o. `lprm` -Remove something from the printer queue. +Remove something from the printer queue. ```bash lprm jobnumber ``` ### p. `ls` -Lists your files. `ls` has many options: `-l` lists files in 'long format', which contains the exact size of the file, who owns the file, who has the right to look at it, and when it was last modified. `-a` lists all files, including hidden files. For more information on this command check this [link](https://ss64.com/bash/ls.html). +Lists your files. `ls` has many options: `-l` lists files in 'long format', which contains the exact size of the file, who owns the file, who has the right to look at it, and when it was last modified. `-a` lists all files, including hidden files. For more information on this command check this [link](https://ss64.com/bash/ls.html). ```bash ls option ``` @@ -240,13 +240,13 @@ drwxr-xr-x 17 adnan staff 578 Mar 27 23:36 .git ### q. `more` -Shows the first part of a file (move with space and type q to quit). +Shows the first part of a file (move with space and type q to quit). ```bash more filename ``` ### r. `mv` -Moves a file from one location to other. +Moves a file from one location to other. ```bash mv filename1 filename2 ``` @@ -266,7 +266,7 @@ rm filename ``` ### t. `tail` -Outputs the last 10 lines of file. Use `-f` to output appended data as the file grows. +Outputs the last 10 lines of file. Use `-f` to output appended data as the file grows. ```bash tail filename ``` @@ -375,7 +375,7 @@ Print lines matching a pattern - Extended Expression (alias for: 'grep -E') *example.txt* ```bash Lorem ipsum -dolor sit amet, +dolor sit amet, consetetur sadipscing elitr, sed diam nonumy @@ -421,7 +421,7 @@ consetetur sadipscing elitr, sed diam nonumy eirmod tempor -foo (Lorem|dolor) +foo (Lorem|dolor) invidunt ut labore et dolore magna aliquyam erat, sed @@ -444,7 +444,7 @@ or grep -F '(Lorem|dolor)' example.txt ``` ```bash -foo (Lorem|dolor) +foo (Lorem|dolor) ``` ### f. `fmt` @@ -482,7 +482,7 @@ amet. ``` ### g. `grep` -Looks for text inside files. You can use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. +Looks for text inside files. You can use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. ```bash grep pattern filename ``` @@ -527,7 +527,7 @@ amet. *show example.txt with line numbers* ```bash -nl -s". " example.txt +nl -s". " example.txt ``` ```bash 1. Lorem ipsum @@ -557,7 +557,7 @@ Stream editor for filtering and transforming text *example.txt* ```bash Hello This is a Test 1 2 3 4 -``` +``` *replace all spaces with hyphens* ```bash @@ -627,7 +627,7 @@ Hello World Foo Bar Baz! *take all lower case letters and make them upper case* ```bash -cat example.txt | tr 'a-z' 'A-Z' +cat example.txt | tr 'a-z' 'A-Z' ``` ```bash HELLO WORLD FOO BAR BAZ! @@ -683,7 +683,7 @@ sort example.txt | uniq -c ``` ### m. `wc` -Tells you how many lines, words and characters there are in a file. +Tells you how many lines, words and characters there are in a file. ```bash wc filename ``` @@ -705,7 +705,7 @@ Where `7459` is lines, `15915` is words and `398400` is characters. ### a. `cd` -Moves you from one directory to other. Running this +Moves you from one directory to other. Running this ```bash $ cd ``` @@ -719,7 +719,7 @@ cd - ``` ### b. `mkdir` -Makes a new directory. +Makes a new directory. ```bash mkdir dirname ``` @@ -728,7 +728,7 @@ You can use this to create multiple directories at once within your current dire mkdir 1stDirectory 2ndDirectory 3rdDirectory ``` You can also use this to create parent directories at the same time with the -p (or --parents) flag. For instance, if you wanted a directory named 'project1' in another subdirectory at '/samples/bash/projects/', you could run: -```bash +```bash mkdir -p /samples/bash/projects/project1 mkdir --parents /samples/bash/projects/project1 ``` @@ -736,7 +736,7 @@ Both commands above will do the same thing. If any of these directories did no already exist, they would be created as well. ### c. `pwd` -Tells you which directory you currently are in. +Tells you which directory you currently are in. ```bash pwd ``` @@ -752,7 +752,7 @@ pwd