Bash Scripting

Class length: 18 weeks. Start anytime.

Creator: kday

Status: Established

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 (3 total):

zlu (Self-grade: Outstanding)
Submitted 7 months ago

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)
Permalink

Comments:

kday
7 months 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

kday (Self-grade: Outstanding)
Submitted 7 months ago

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.

Permalink
johnny (Self-grade: Pretty good)
Submitted 7 months ago

done.

Permalink

Comments:

kday
7 months ago

Cool, nice work.

Sign up or log in to comment

Recent Class Activity

jvleta joined Bash Scripting
2 weeks ago
BTheMad joined Bash Scripting
1 month ago
bhrgunatha submitted Lesson 3 HW 1
2 months ago
rch joined Bash Scripting
2 months ago
kday commented on johnny's homework
2 months ago
bhrgunatha submitted Lesson 2 HW 1
2 months ago
bhrgunatha commented on johnny's homework
2 months ago
kday submitted Lesson 8 HW 1
2 months ago

Class Members (74)

jvleta
Joined 2 weeks ago
BTheMad
Joined 1 month ago
rch
Joined 2 months ago
adaptives
Joined 2 months ago
bhrgunatha
Joined 2 months ago
kksm19820117
Joined 3 months ago
kevinelliott
Joined 3 months ago
JessicaParkers
Joined 4 months ago

All members


License

Attribution Non-Commercial Share Alike