Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions 01-read_input_PTH.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# read the name of the user and print hello

echo "Hello! What is your name"
read name
echo "Welcome, $name"

# single quotes prevent the expansion of the variable
echo 'Your name was stored in $name'

# exercise: write a script that asks the user for a
# filename and create an empty file named after it

echo "Hey $name, What is your filename?"
read filename
echo "You want $filename"
echo "Creating $filename ..."
touch $filename
echo "$filename creted"
ls
echo "Bye,bye"
25 changes: 25 additions & 0 deletions 07-beer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,28 @@ while [ $count -ge 0 ]; do
((count = count - 1))

done

# PTH -- Exercise from above

echo "Now we sing about syntax errors!"
echo "How many syntax errors?"
read count

while [ $count -ge 0 ]; do
if [ $count -ge 2 ]; then
echo "$count little syntax errors causing pains in my head"
echo "changed one line and now my program's dead"
echo "Peyton called the professor and the professor said"
echo "No more syntax errors making your programs dead!"
else
echo "$count little syntax errors causing pains in my head"
echo "changed one line and now my program's dead"
echo "Peyton called the professor and the professor said"
echo "No more syntax errors making your programs dead!"
echo "THIS PROGRAM HAS BEEN SLIGHTLY CHANGED FOR THE EXERCISE"
echo "editing for the fifth fourth time absolutely hating this"
fi

((count = count - 1))

done
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.