Skip to content

Commit

Permalink
content-update
Browse files Browse the repository at this point in the history
  • Loading branch information
BitwiseOperator committed Jun 19, 2024
1 parent 28b3149 commit 30381f6
Showing 1 changed file with 35 additions and 22 deletions.
57 changes: 35 additions & 22 deletions docs/Knowledge_Base/Coding_&_Scripting/Bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
done
```

!!! info ""

#### If statement

`$1` here represent the first argument.
Expand All @@ -30,6 +32,8 @@
fi
```

!!! info ""

#### If/Else

```bash
Expand All @@ -42,6 +46,8 @@
fi
```

!!! info ""

#### Command line arguments

Command line arguments are represented like this
Expand All @@ -54,6 +60,8 @@

This is the first command line argument

!!! info ""

#### Daemonize an execution

If you do a ping-sweep with host the command will take about a second to complete. And if you run that against 255 hosts I will take a long time to complete. To avoid this we can just deamonize every execution to make it faster. We use the `&` to daemonize it.
Expand All @@ -66,6 +74,8 @@
done
```

!!! info ""

#### Use the output of command

It has happened to me several times that I want to input the output of a command into a new command, for example:
Expand All @@ -87,6 +97,31 @@
```


#### Iterate over a file

This script will iterate over a file and echo out every single line

```bash
#!/bin/bash

for line in $(cat file.txt);do
echo $line
done
```

Another way of writing is this

```bash
#!/bin/bash

while read p; do
echo $p
done <file.txt
```


!!! info ""

#### picoCTF flag save

```bash
Expand Down Expand Up @@ -120,25 +155,3 @@
Now that would have created a get_flag.sh and a flag.txt
you can cat the txt file for the flag
```

## Iterate over a file

This script will iterate over a file and echo out every single line

```bash
#!/bin/bash

for line in $(cat file.txt);do
echo $line
done
```

Another way of writing is this

```bash
#!/bin/bash

while read p; do
echo $p
done <file.txt
```

0 comments on commit 30381f6

Please sign in to comment.