Stop learning alone!

Learn faster and stay on-track by joining this free class with other self-learners.

Register for Bash Scripting now.

Bash Scripting

Class length: 18 weeks. Start anytime.

Creator: kday

Status: Established

Join this class!

Lesson 3: Assignment 1: Problem set 1

Do all of the examples throughout Chapter 4 in Bash Cookbook by O'Reilly.

To submit the homework, just leave a comment saying that you completed it and mention any problems you had or any cool things you learned. Don't print out your whole session history, it gets really long really fast. Do post code specific examples that you want to discuss.

If you copy and paste any of your bash history, make sure that you don't post anything sensitive. Create dummy directories for working with files, don't post any passwords, etc.

The assignment should take about 30 to 45 minutes to complete.

Homework Submissions

6 total

rohshall (Self-grade: Outstanding)
Submitted 4 months ago | Permalink | Time spent: 1 minute

/usr/bin/env sh

for SCRIPT in /sbin/*; do if [ -f $SCRIPT -a -x $SCRIPT ]; then echo "$SCRIPT" fi done

ahunsaker (Self-grade: Outstanding)
Submitted 9 months ago | Permalink | Time spent: 30 minutes

Completed work. I have worked with the && || nohup has come in handy when needing to leave and have the job continue.

bhrgunatha (Self-grade: Outstanding)
Submitted 1 year ago | Permalink

Weird I knew about using && || and & in scripts and commands, but never came across running commands sequentially separated by a semi-colon. Weird what gaps we have in our knowledge.

kday (Self-grade: Outstanding)
Submitted 2 years ago | Permalink | Time spent: 20 minutes

Nice chapter. I've been looking for something similar to nohup for a long time. I've actually resorted to using cron at times for one-off long running tasks. nohup is going to save me a lot of trouble :)

johnny (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

Discussion in 4.8.3 has a nice one-liner for running a command and verbosely exiting if it fails: cmd || { printf "%b" "FAILED.\n" ; exit 1 ; }

set -e could also be interesting, but I have typically wrapped most if not all of my commands in 'if' or 'while' loops which negates the effect.

zlu (Self-grade: Outstanding)
Submitted 2 years ago | Permalink

easy chapter