3 ms·
Also, just get to know your shell. big timesaver: control-r basic but useful all over: for i in *.c; do cp "$i" "$i.bak"; done etc...
by m463 8y ago
Also, just get to know your shell.
big timesaver: control-r
basic but useful all over:
for i in *.c; do cp "$i" "$i.bak"; done
etc...
- hi41 8y agoWhat does double quotes dollar do in the command?
- MHP47 8y ago$i is the variable i declared in the for loop. Quotes just wraps it, so that it's (somewhat) safe if the file has a space in the name
- majewsky 8y agoWhat do you mean, "somewhat"? This looks safe for all I can tell.
- akx 8y agoEnsures filenames with spaces in them get passed as a single argument, instead of being inadvertently expanded into several. Quoting and expansion issues are a pain in shell languages...
- deleted 8y ago[deleted]
- nickjj 8y agoYou know how you should almost always eat your vegetables? You should almost always quote your Bash variables too. Here's why: https://nickjanetakis.com/blog/here-is-why-you-should-quote-your-variables-in-bash https://nickjanetakis.com/blog/here-is-why-you-should-quote-...
- aoeusnth1 8y agoIt prevents filenames with spaces from expanding into two arguments to the command.