From 0ceecf342314f69635e7a9642431ab5bc86b48de Mon Sep 17 00:00:00 2001 From: benjamyn Date: Mon, 25 Feb 2019 03:27:55 +1100 Subject: [PATCH] Added in data stream info --- docs/commands.md | 10 +++++++--- docs/examples/lsof.md | 4 +++- docs/examples/regexmatch.md | 7 ++++--- docs/shellbasics.md | 19 +++++++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 docs/shellbasics.md diff --git a/docs/commands.md b/docs/commands.md index b7f77d8..fd987ac 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -1,6 +1,6 @@ -#Commands +# Commands -## Files +## Manipulating files Commands that can be used for reading and manipulating files @@ -49,8 +49,12 @@ Commands that can be used for reading and manipulating files Some examples of grep usage can be found [here](/examples/grep) -### losof +### lsof `lsof` is a command that will show you what processes have specified file open currently you can see an example [here](/examples/lsof) +## Manipulating the standard input + +These commands can be used to manipulate data in the standard input + ### rev \ No newline at end of file diff --git a/docs/examples/lsof.md b/docs/examples/lsof.md index 54e1f18..28ea6a3 100644 --- a/docs/examples/lsof.md +++ b/docs/examples/lsof.md @@ -1,6 +1,8 @@ # lsof examples -`[ben@jamyn] ~/Documents/Projects/Python/mkdocs-pages$ lsof docs/index.md` +In this example we can see that the docs/index.md file is currently open by the tail command + +`[ben@jamyn ~/Documents/Projects/Python/mkdocs-pages]$ lsof docs/index.md` ```bash COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME diff --git a/docs/examples/regexmatch.md b/docs/examples/regexmatch.md index 93989f9..e050cc7 100644 --- a/docs/examples/regexmatch.md +++ b/docs/examples/regexmatch.md @@ -1,11 +1,12 @@ -#Regex examples +# Regex examples -##Match an IP address +## Match an IP address `\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}` -If we use this expression on the following using grep to search the file +If we use this expression on the following using grep to search the file `grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' log.txt'` + ```bash 103.252.153.201 127.0.0.1 - - [30/Dec/2018 22:43:01] "GET / HTTP/1.0" 200 - diff --git a/docs/shellbasics.md b/docs/shellbasics.md new file mode 100644 index 0000000..f00c52e --- /dev/null +++ b/docs/shellbasics.md @@ -0,0 +1,19 @@ +# Basics of the linux shell + +## Streams + +The linux shell (this will usually be [`bash`](bash.md)) works using different streams + +The main three streams that are used on the command line are STDIN (Standard input), STDOUT (Standard output), STDERR (Standard Error) + +|ID|STREAM|USE| +|---|:----|:---| +| 0 | STDIN | Used to send input to the program | +| 1 | STDOUT | Used to receive output from the program | +| 2 | STDERR | Used to receive errors from the program | + +### Standard Input + +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) \ No newline at end of file