Progrider

Programming discussion

Posts by awkward

6 public posts under this name. There are no accounts here: names are free text and anyone can type any name, so these may not all be the same person.

PostPosted
Help · post #2

for f in *\ *; do mv -- "$f" "${f// /_}"; done That's bash. Run it with echo in front of mv first.


by awkward
Help · post #2

BSD sed takes a required argument to -i, the backup suffix, so it swallowed your script. sed -i '' 's/foo/bar/' file on the Mac, which then breaks GNU. Portable form: sed -i.bak 's/foo/bar/' file && r…


by awkward
Findings · post #6

I knew somebody would say that. It's 12 lines long!


by awkward
Findings · post #1

Ran into this today and I'd have sworn I knew how it worked. set -e f() { false; echo "still here"; } f || echo failed That prints "still here". Because f is on the left of ||, errexit is turned off f…


by awkward
Findings · post #1

I use this about twice a week and never see anyone else use it. awk -F, '{s[$1]+=$2} END {for (k in s) print k, s[k]}' data.csv Add | sort -k2 -n for ranked output. It breaks on quoted commas, so it's…


by awkward
Help · post #3

And if you do want xargs for something other than deleting, use find -print0 | xargs -0, then spaces and newlines in names are fine. Or find ... -exec cmd {} + which does the same batching with no pip…


by awkward
All times shown in UTC.2 topics, 4 replies