Skip to content

Commit

Permalink
DOC: Add bash heredocs and file existence flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Lugg committed Oct 7, 2018
1 parent 1c316c7 commit 9d7447e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/useful_commands/bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
| `$USERNAME` | Logged-in username |
| `$HOME` | Home directory path |
| `$BASH_VERSION` | Shell version |
| `[[ -d directory ]]` | Test a directory exists |
| `[[ -f file ]]` | Test a file exists |
| `[[ -e file_or_directory ]]` | Test for existence of file or directory |

Colours in bash: [guide](https://gist.github.com/vratiu/9780109)

Expand Down Expand Up @@ -168,3 +171,29 @@ Function return values can be accessed and assigned to a variable via command su
```bash
output=$( my_function arg1 arg2 ... )
```
## HereDocs
```bash
command << delimiter
line1
line2
line3
delimiter
```
Ignore tabs by using `-`, e.g.:
```bash
cat <<- EOF
line1
line2
line3
EOF
```
Send to a file:
```bash
cat > myfile <<- xxx
Content
More content
xxx
```

0 comments on commit 9d7447e

Please sign in to comment.