Added in linux shell basics

This commit is contained in:
Benjamyn Love 2019-02-25 03:47:36 +11:00
parent 0ceecf3423
commit 833244037f
2 changed files with 23 additions and 2 deletions

View File

@ -8,4 +8,5 @@ This is a compendium of all the useless facts, tips, tricks and commands that I
## Quick Links ## Quick Links
[Commands](commands) [Linux Shell Basics](/shellbasics)
[Commands](/commands)

View File

@ -16,4 +16,24 @@ The main three streams that are used on the command line are STDIN (Standard inp
Standard input is how we send input to an application it is also how we interact with the command line shell (Usually [`bash`](/bash.md)) Standard input is how we send input to an application it is also how we interact with the command line shell (Usually [`bash`](/bash.md))
Once thing that makes the linux command line so powerfull is the suite of commands that is provided all work using STDIN, STDOUT and STDERR you can pipe information from one stream to another (i.e the STDOUT from one program can be in STDIN to another) Whenever a linux program asks for input this is sent to the program using the STDIN stream
The STDIN stream can also be refrenced by the '-' char in a command line application `cat -` will print what comes into STDIN (The terminal)
One thing that makes the linux command line so powerfull is the suite of commands that is provided all work using STDIN, STDOUT and STDERR you can pipe information from one stream to another (i.e the STDOUT from one program can be in STDIN to another)
#### Input Redirection
You can use redirection to send information to a program using the '<' symbol i.e `cat < file` this will push the contents of 'file' to cat using STDIN
### Standard Output
Standard output is how we get the output from a program, usually this is printed directly to the terminal
#### Output Redirection
You can redirect the STDOUT of a application is a few ways you can use the '>' symbol to push the information from the programs output and saves it in a file for example `ls > filelist` will take the output of ls and saves it in the filelist file
You can also redirect the STDOUT of one program to another programs STDIN using the '|' symbol doing this you can combine muliple programs in different ways
For example you can use `ls -alh | grep filename` this will list the files in the current directory and then passes the STDOUT to the STDIN for grep, this causes grep to use the output of ls as the input data to work with so the output of ls is searched for the string 'filename'