Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hello World:
- #!/bin/bash
- echo Hello World!
- Shebang:
- #!/usr/bin/python3
- print("I'm beeing run in python3")
- Simple Backup:
- #!/bin/bash
- tar -cZf /var/backup.tgz /home/linux
- Variables:
- #!/bin/bash
- variable="Inhalt"
- echo #variable
- If/Else:
- #!/bin/bash
- variable="Inhalt"
- if [ $variable == "Inhalt" ]
- then
- echo true
- else
- echo false
- fi
- For-Loop:
- #!/bin/bash
- for i in $(seq 1 10)
- do
- echo $i
- done
- For item in x:
- #!/bin/bash
- for item in `ls`
- do
- echo item: $item
- done
- While:
- #!/bin/bash
- COUNTER=0
- while [ $COUNTER -lt 10 ]
- do
- echo $COUNTER
- let COUNTER=COUNTER+1
- done
- Until:
- #!/bin/bash
- COUNTER=20
- until [ counter -lt 10 ]
- do
- echo $COUNTER
- let COUNTER-=1
- done
- Funktion:
- #!/bin/bash
- function hello{
- echo Hello!
- }
- hello
- exit
- Funktion und Parameter:
- #!/bin/bash
- function e{
- echo $1
- }
- e hello
- e hello world
- e "Hello World!"
- Interface:
- #!/bin/bash
- OPTIONS="Hello Done"
- select opt in $OPTIONS
- do
- if [ "$opt" = "Quit" ]
- then
- echo done
- exit
- elif [ "$opt" = "Hello" ]
- then
- echo Hello World!
- else
- clear
- echo bad option
- fi
- done
- Debug:
- #!/bin/bash -x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement