[deleted]
Re:Bash Academy
by AdmiralAsshat on Tuesday December 15, 2015 @09:27AM
(#10737878)
As opposed to improper bash? Get off your high horse.
There is very much a bad way of doing bash. When I first started doing bash scripts, most of them looked like this:
cat file | grep string
cat file | wc
cat file | while read line
Multiple problems there. Then there was my initial attempts at finding files in a directory:
for i in `ls *`
This is when I learned about globbing.
There is enough variance in how things can be done in Bash with varying degrees of effectiveness that Google even has a Shell Style Guide: https://google.github.io/styleguide/shell.xml
We all get tricked by the "useless use of cat" thing occasionally :)
I'm not so sure it is so useless. Consider when you want to "grep something access.log". Then you want to look at yesterday's so it's "grep something access.log.1". Then you want to look at the log before that, but it's compressed. "gunzip -c access.log.2.gz | grep something". (Ignore zgrep for the moment. Let's say I want to use grep's -A and -B options to show context of the lines that it finds.) To switch between the compressed and uncompressed files, you have to move the filename to a completely different part of the command, which requires more re-typing. You would have been better off starting with so-called "useless" cat. Separate out the concern of "putting a stream into the pipe" from "doing something with the stream". gunzip -c is just one command that might produce output.
Thanks for the link to the Google Bash Style Guide. A good read.
Re:Bash Academy
by nomadictribe on Tuesday December 15, 2015 @10:08AM
(#10738117)
https://google.github.io/styleguide/shell.xml
my fx doesn't render the site properly it's just one huge blob of continuous text. impossible to read. why would they do it as an *.xml?
Re:Bash Academy
by narrowrail on Tuesday December 15, 2015 @12:28PM
(#10739025)
You could try this version:
https://github.com/google/styleguide/blob/gh-pages/shell.xml
It's an XSL document. I guess your browser settings block using XSL stylesheets to render the XSL document correctly.
Oh come on! It is clear that English is not his first language. Give him a break.
Re:Bash Academy
by michaelmior on Tuesday December 15, 2015 @09:16AM
(#10737826)
It's entirely possible to learn improper bash when cobbling stuff together over the years. I've certainly done a few things that I've since found much better alternatives for.