Added many more pages

This commit is contained in:
Benjamyn Love 2019-01-03 10:36:29 +11:00
parent e114ec4c70
commit 9c85051fab
5 changed files with 113 additions and 1 deletions

View File

@ -1,9 +1,21 @@
#Commands #Commands
##Files ##Files
###tail ###tail
`tail` by default reads the last 5 lines of the input file and then exits `tail` by default reads the last 5 lines of the input file and then exits
| Useful Flags | Function |
| ------------- |:-------------|
| -n *x* | Returns the last x lines of a file |
| -f | Follows the end of the file, so any new data will be printed out to the screen |
###head
`head` by default reads the first 5 lines of the input file and then exits
| Useful Flags | Function |
| ------------- |:-------------|
| -n *x* | Returns the first x lines of a file |
###awk ###awk
`awk` is used to extract, layout and modify data using the command line (It is way more then this but its all I use it for) `awk` is used to extract, layout and modify data using the command line (It is way more then this but its all I use it for)
@ -14,10 +26,22 @@
| Useful Flags | Function | | Useful Flags | Function |
| ------------- |:-------------| | ------------- |:-------------|
| -i | in-place, writes the changes to the file | | -i | In-place, writes the changes to the file |
| -f | Use a script file instead of reading the expression from STDIN | | -f | Use a script file instead of reading the expression from STDIN |
###grep ###grep
`grep` is used to match text in a file,
| Useful Flags | Function |
| ------------- |:-------------|
| -o | Returns only the matched data (Useless without regex really) |
| -E | Allows extended regex to be used in the search, [regex info](/regex)|
| -P | Allows the use of Perl regex, this uses a different syntax to -E |
| -i | Makes the search case insensitive |
| -r | Searches files recursively (i.e if you have quite a few files and folders it will search through all of them) |
| -l | Returns the filename where the data was matched instead of the matched data |
Some examples of grep usage can be found [here](/examples/grep)
###rev ###rev

2
docs/examples/grep.md Normal file
View File

@ -0,0 +1,2 @@
#Grep examples

View File

@ -0,0 +1,59 @@
#Regex examples
##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
`grep -oP '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' log.txt'`
```
103.252.153.201
127.0.0.1 - - [30/Dec/2018 22:43:01] "GET / HTTP/1.0" 200 -
210.49.93.254, 66.102.6.169
127.0.0.1 - - [31/Dec/2018 09:17:47] "GET / HTTP/1.0" 200 -
210.49.93.254, 66.102.6.173
127.0.0.1 - - [31/Dec/2018 09:17:48] "GET /favicon.ico HTTP/1.0" 200 -
112.140.176.2
127.0.0.1 - - [01/Jan/2019 01:58:43] "GET / HTTP/1.0" 200 -
112.140.176.2
127.0.0.1 - - [01/Jan/2019 01:58:45] "GET /favicon.ico HTTP/1.0" 200 -
112.140.176.2
127.0.0.1 - - [01/Jan/2019 01:58:51] "POST / HTTP/1.0" 200 -
112.140.176.2
127.0.0.1 - - [01/Jan/2019 01:58:51] "GET /favicon.ico HTTP/1.0" 200 -
112.140.176.2
127.0.0.1 - - [01/Jan/2019 02:13:07] "GET /EviXDWpXvH HTTP/1.0" 200 -
210.49.93.254, 66.102.6.171
127.0.0.1 - - [02/Jan/2019 10:32:17] "GET / HTTP/1.0" 200 -
210.49.93.254, 66.102.6.173
127.0.0.1 - - [02/Jan/2019 10:32:18] "GET /favicon.ico HTTP/1.0" 200 -
```
The output will be a list of IP addresses in the file that looks like
```
103.252.153.201
127.0.0.1
210.49.93.254
66.102.6.169
127.0.0.1
210.49.93.254
66.102.6.173
127.0.0.1
112.140.176.2
127.0.0.1
112.140.176.2
127.0.0.1
112.140.176.2
127.0.0.1
112.140.176.2
127.0.0.1
112.140.176.2
127.0.0.1
210.49.93.254
66.102.6.171
127.0.0.1
210.49.93.254
66.102.6.173
127.0.0.1
```

26
docs/regex.md Normal file
View File

@ -0,0 +1,26 @@
#Regex
I am by no means an expert when it comes to regex, this document will propbably have some inaccuracies in it but hey it is what it is :)
##What is regex?
Regex is shorthand for regular expressions, it is a system for pattern matching in text, when combined with commands it can be used for quite a lot of things
##Useful regex patterns
* **.** \- Matches any char
* **^** \- Matches at the start of a line
* **$** \- Matches at the end of a line
* **?** \- Matches once or none
* **+** \- Matches once or more
* **\*** \- Matches zero or more times
* **\d** \- Match any decimal (0-9)
* **\b** \- Defines a word boundary
* **{x}** \- Repeat exactly x times
* **{x, y}** \- Repeat pattern x to y times
##Regex logic
* **|** \- Logical OR, allows pattern1 OR pattern2 to match
* **(x|y)** \- Matches a group of patterns
I have made a few examples [here](/examples/regexmatch)

View File

@ -3,4 +3,5 @@ nav:
- Home: index.md - Home: index.md
- Commands: commands.md - Commands: commands.md
- Connections: connections.md - Connections: connections.md
- Regex: regex.md
theme: readthedocs theme: readthedocs