|
Bash ScriptingClass length: 18 weeks. Start anytime. Creator: kday Status: Established |
|
Assignment 1: Problem set 1Do all of the examples throughout Chapter 2 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. Bash Tip: If you want to stop a command cleanly, type 'Ctrl + C'. Homework Submissions (5 total):I couldn't get 2.12 to work, Skipping a Header in a File. tail kept trying to open the file '+2' and gave an error (see below). I also skipped a couple towards the end like 2.19 and 2.20. The rest of the examples worked well, and I learned more than I expected to given it's the first chapter. kevin@heater:~/bashtest2$ tail +2 /tmp/ls.out tail: cannot open `+2' for reading: No such file or directory ==> /tmp/ls.out <== k s a d f g h j k s kevin@heater:~/bashtest2$ tail /tmp/ls.out +2 ==> /tmp/ls.out <== k s a d f g h j k s tail: cannot open `+2' for reading: No such file or directoryPermalink All done... (better late then never). The crazy file redirection was new to me e.g. 3>&1 1>&2 2>&3. Comments:Cool. No problem on the lateness. Glad you're able to join the action. I read only whatever the O'Reilly preview allowed - which is not very less since only a few pages seem to have been skipped.
In particular, I could not read 2.4,5,10,11,12,17,18,22 parts. However, I can guess they are about "echo -n", ">>", head, tail, xargs, and ">!". Am I correct? :) The 'type' command and the swapping of STDOUT and STDERR were new and very useful to me. I'm planning to get an ebook version of this book soon. No comments. Sign up or log in to comment These are the things I learned that surprised me ls formatting depends on whether its output is going to the terminal or a file.
() runs in a subshell using pipes causes commands to run in subshells tee duplicates output : ... uniq | tee /tmp/x.x | awk -f transform.awk ... $() uses output of subshell as a string e.g. rm $(find . -name '*.rb') equivalent to backticks `` No comments. Sign up or log in to comment |
Comments:
6 months ago
what happens when you do: tail /tmp/ls.out
6 months ago
Try this:
6 months ago
tail /tmp/ls.out worked fine a produced the list that was displayed twice.
pbr's suggestion worked. Thanks! Here's my output for a /tmp/ls.out with slighly different content:
6 months ago
i can't understand 2.18. could someone upload an example of what the 'divert' script may look like?
6 months ago
Sorry, I can't help on that one. I skipped it too. I figured if I had a script with multiple types of output I can come back to that example. I haven't faced that kind of scenario yet though.
6 months ago
to expand on pbr's comment, this is from the man page:
so either --lines or -n will work.
6 months ago
Thanks, johnny, that makes sense. For some reason the book says that if you use a + sign then it has the same effect as -n or --lines. Apparently didn't work for me.
Sign up or log in to comment