Created
May 24, 2020 05:58
-
-
Save tallguyjenks/44b2be3e06bb17d9c9d6a0d6abc92645 to your computer and use it in GitHub Desktop.
Introduction to Bash Scripting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
##!/bin/bash | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Variables | |
#var1="hello" | |
#echo $var1 | |
#var2="hello" | |
#echo $var2 | |
#my_dir=pwd | |
#echo $my_dir | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Command Substitution | |
#my_dir=$(pwd) | |
#echo $my_dir | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Arrays | |
#arr=(hello world) | |
#arr="hello world" | |
#echo ${arr[0]} | |
#echo ${arr[1]} | |
#echo ${#arr[*]} | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Quoting | |
#echo "$(pwd)" | |
#echo '$(pwd)' | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Math | |
#result=$((4 + 6)) | |
#echo $result | |
#echo "$result" | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Tests Statements | |
#echo $([ -z "hi" ]) | |
#echo $([ -z "" ]) | |
#echo $([ ! -z "" ]) | |
#[ -z "" ] && echo "hi" | |
#[ -z "hi" ] ; echo "hi" | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# If Statements | |
#if [ -z "hi" ]; then echo "hi" | |
#fi | |
#if [ -z "" ]; then echo "hi" | |
#fi | |
#if [ -z "" ] && [ 0=0 ]; then echo "hi" | |
#fi | |
#if [ -z "hi" ] || [ 0=0 ]; then echo "hi" | |
#fi | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Case Statements | |
#filetype=".md" | |
#filetype=".tex" | |
#filetype=".rmd" | |
#filetype=".Rmd" | |
#filetype=".c" | |
#case "$filetype" in | |
# *.md) echo "You chose markdown" ;; | |
# *.tex) echo "you chose a TeX file!" | sed 's/!/, and LaTeX is best/g' ;; | |
# *.[rR]md) echo "you chose R Markdown" ;; | |
# *) echo "you chose nothing, this is the default" ;; | |
#esac | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# loops | |
# While Loops | |
#counter=1 | |
# | |
#while [ $counter -le 10 ] | |
#do | |
# echo $counter | |
# ((counter++)) | |
#done | |
# | |
#echo All done | |
# Until loops | |
#counter=1 | |
# | |
#until [ $counter -gt 10 ] | |
#do | |
# echo $counter | |
# ((counter++)) | |
#done | |
# | |
#echo All done | |
# For loops | |
#names='Stan Kyle Cartman' | |
# | |
#for name in $names #why is this unquoted | |
#do | |
# echo $name | |
#done | |
# | |
#echo All done | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Brace Expansion & ranges | |
#for value in {1..5} | |
#do | |
# echo $value | |
#done | |
# | |
#echo All done | |
#touch {file1,file2,file3}.md | |
#touch test_file{1..5} | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Globbing through wild cards | |
#rm test_file* | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# regex | |
#grep "^\- \[x\]*" ~/notes.md | |
#My regex video | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Functions | |
#function myFunc() { | |
# echo -e "this is bad practice" | |
#} | |
#myFunc() { | |
# echo "this is good practice" | |
#} | |
# | |
#myFunc | |
#===#===#===#===#===#===#===#===#===#===#===#===#===#===#===#=== | |
# Shell Check | |
# Github scripts with shell check and travis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment