Shell scripting

Read Introduction, Basics, and Beyond the Basics from the Advanced Bash-Scripting Guide.

Exercise: Write a shell script that asks the user for their name, and greets them. Sample interaction:

$ bash ./greeter
What's your name? <RETURN>
What's your name? Hippopotamus
Hello, Hippopotamus!
$ 

Exercise: Write a shell script that performs "ROT13" (Caesar cipher with shift 13.) For English, encryption and decryption are the same! (Explain why!) Sample interaction:

$ echo hello | bash ./rot13
uryyb
$ echo uryyb | bash ./rot13
hello
$ echo hello | bash ./rot13 | bash ./rot13
hello

Exercise: Write a shell function that prints "hidden" if the current directory starts with a dot ".", or if any parent starts with a dot. (Files and directories that start with dots are considered "hidden" on many UNIX-like systems.) Sample interaction:

$ pwd
/home/nlhowell
$ bash ~/hidden
$ mkdir .secretdir
$ cd ./.secretdir
$ bash ~/hidden
hidden
$