Skip to content
ImagineWorld

Appendix B: Shell Scripting Reference

node_idnode-book_suse-certified-administrator_appendix-b-shell-scripting-reference
node_typebook-part
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_titleAppendix B: Shell Scripting Reference
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Shell scripts automate repetitive tasks and make system behavior consistent. Below is a compact reference.

#!/bin/bash
echo "Hello from script"
Terminal window
NAME="SUSE"
echo $NAME
Terminal window
read -p "Enter your name: " USERNAME
Terminal window
if [ -f /etc/hosts ]; then
echo "File exists"
else
echo "File missing"
fi
Terminal window
for i in 1 2 3; do
echo $i
done
Terminal window
backup() {
cp $1 $1.bak
}
backup /etc/hosts
Terminal window
echo $? # Show exit value of last command
Terminal window
chmod +x script.sh
./script.sh