change formatting

input examples are now given as

```bash
input $ARG1
```

While outputs use md's '> ' sign as a quote.
This commit is contained in:
2023-06-17 21:28:20 +02:00
parent 1ba3010b81
commit ba8026e0c3
102 changed files with 2388 additions and 3211 deletions

View File

@@ -8,39 +8,55 @@ See a file's contents:
Return full contents of a string:
> awk '{ print }' file
```bash
awk '{ print }' file
```
Print the first and second column:
> awk '{print$1$2}'
```bash
awk '{print$1$2}'
```
Return every line with the word 'the' (like grep):
> awk '/the/{print}' file
```bash
awk '/the/{print}' file
```
Print everything containing a lowercase letter:
> awk '/[a-z]/{print}' file
```bash
awk '/[a-z]/{print}' file
```
Same with numbers [0-9], or using a caret we can show lines starting with a number - ^[0-9], or ending with an uppercase letter - $[A-Z].
# Conditionals
> awk '{ if($1 ~ /123/) print }' file
```bash
awk '{ if($1 ~ /123/) print }' file
```
Check if the first column is equal to 1 or 2 or 3, and if so then print that line.
Grep for 'hawk' in a story:
> awk '/hawk/' story.txt
```bash
awk '/hawk/' story.txt
```
Return any line with one or more "&" sequences:
> awk '/&+/' script.sh
```bash
awk '/&+/' script.sh
```
The pipe is used for 'or', so 'Orcs or drums' would be:
> awk '/Orcs|Drums/' story.txt
```bash
awk '/Orcs|Drums/' story.txt
```
Basic variables are: