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
book_parentnode-book_suse-certified-administrator
chapter_titleAppendix B: Shell Scripting Reference
next_chapternode-book_suse-certified-administrator_appendix-c-common-system-troubleshooting-playbooks
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph
Appendix B: Shell Scripting Reference
Section titled “Appendix B: Shell Scripting Reference”Shell scripts automate repetitive tasks and make system behavior consistent. Below is a compact reference.
Basic Script Structure
Section titled “Basic Script Structure”#!/bin/bashecho "Hello from script"Variables
Section titled “Variables”NAME="SUSE"echo $NAMEread -p "Enter your name: " USERNAMEConditions
Section titled “Conditions”if [ -f /etc/hosts ]; then echo "File exists"else echo "File missing"fifor i in 1 2 3; do echo $idoneFunctions
Section titled “Functions”backup() { cp $1 $1.bak}backup /etc/hostsExit Codes
Section titled “Exit Codes”echo $? # Show exit value of last commandRun Script
Section titled “Run Script”chmod +x script.sh./script.sh