[clug] Pointless time-wasting bash questions

Bob Edwards Robert.Edwards at anu.edu.au
Fri Jun 26 00:15:28 MDT 2015

On 26/06/15 15:44, Paul Harvey wrote:
> On 26 Jun 2015 15:26, "Bob Edwards" <Robert.Edwards at anu.edu.au
> <mailto:Robert.Edwards at anu.edu.au>> wrote:
>  > In the example above, the quotes add nothing but noise unless you
>  > also change the wordlist to include names with spaces etc.
>     That's true, but I feel there's a bit of irony that you mention code
>     audit here because the only reason I started quoting everything is
>     so that I don't have to reason about the scope/content/provenance of
>     variable contents.
>     I actually learnt this habit from the shellfire project code style,
>     andhttp:// <http://shellcheck.net>shellcheck.net
>     <http://shellcheck.net> complains if you fail to quote variables.
>     This is why I came to CLUG, I've only had things like shellcheck,
>     stackoverflow, and the occasional misleading tutorial
> to teach myself odd habits, it's good to see how people are using the tools.

First up, welcome to CLUG - glad you made it along last night.

So, why not just:

for i in /GenericAgent. . ; do cp Kernel/Config"$i"pm{.dist,} ; done

(which works just as well). Or (to start getting pathologic):

for i in /GenericAgent. . ; do cp Kernel/Config"${i}"pm{.dist,} ; done


for i in /GenericAgent. . ; do cp Kernel/"Config${i}"pm{.dist,} ; done

Again, the quotes aren't actually doing anything here (except in the
first instance above: you do need something to delimit the variable i
from the "pm", but it could just as easily be Config$i"pm" etc.) and
it doesn't really matter where you put them, hence my suggestion that
they are seemingly random.

You mention stackoverflow, and I found this stackoverflow article
helpful on this topic:


Bob Edwards.

More information about the linux mailing list