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 4: Assignment 1: Problem set 1

Do all of the examples throughout Chapter 5 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 45 minutes to an hour to complete.

Homework Submissions

5 total

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

F1NAME=${1:-/bin/ls -l} F2NAME=${2:-assignment.sh}

$F1NAME "$F2NAME"

ahunsaker (Self-grade: Pretty good)
Submitted 9 months ago | Permalink | Time spent: 55 minutes

completed

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

done.

Comments:

kday
2 years ago

Cool, nice work.

Sign up or log in to comment

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

Useful chapter. It's complicated to keep track of the different ways that parameters can be parsed. Now I see why a cookbook is a useful format for bash. Lots of syntax gotchas.

String manipulation operators are cool, but seem hard to remember also.

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

it was straightforward except for the 4th pattern in table 5-1 of problem 5.18. name##pattern

> O="i am bad"
> echo ${O##a}
> i am bad
but i am expecting > d (just d, since it is what's left after the longest front-anchored pattern has been removed)

Comments:

kday
2 years ago

Yeah, I found that a little confusing also. The ## and %% seemed to make more sense when using a wildcard pattern instead of an exact match. See what I tried below.

In your example, I think it returns the full string because your string begins with i and it's trying to match something that begins with a. That's not how I thought it would behave but I think that's what it's doing.

> MYSTR=hellohellobyebye
> echo ${MYSTR#*o}
hellobyebye
> echo ${MYSTR##*o}
byebye

Sign up or log in to comment