Learn faster and stay on-track by joining this free class with other self-learners.
|
Bash ScriptingClass length: 18 weeks. Start anytime. Creator: kday Status: Established |
Join this class! |
|
Lesson 4: Assignment 1: Problem set 1Do 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 Submissions5 totalF1NAME=${1:-/bin/ls -l} F2NAME=${2:-assignment.sh} $F1NAME "$F2NAME" completed No comments. Sign up or log in to comment done. 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. No comments. Sign up or log in to comment 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:Yeah, I found that a little confusing also. The In your example, I think it returns the full string because your string begins with > MYSTR=hellohellobyebye
> echo ${MYSTR#*o}
hellobyebye
> echo ${MYSTR##*o}
byebye
|
No comments. Sign up or log in to comment