Progrider

Programming discussion

Search

Searches topics and replies. Every word has to appear in the post.

28 posts found.

PostPosted
Help · post #4

bash one worked. thanks


by Anonymous
Help · post #3

rename 's/ /_/g' * if you've got the Perl one. On Debian that's the rename package. The util-linux rename on some other distros has different arguments, and I've seen that catch people out.


by old_perl_guy
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 #1

Is there a one liner? They're all in one directory.


by Anonymous
Help · post #3

.bak it is. solved


by wren
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 && rm file.bak. Or perl -pi -e.


by awkward
Help · post #1

script works on my linux box and fails on my work mac sed -i 's/foo/bar/' file sed: 1: "file": invalid command code f


by wren
Help · post #5

I said nothing.


by lintroller !-TjZOnKc
Help · post #4

got most of it back with photorec, filenames are gone though. using -n from now on. dont say anything lintroller


by pbj
Help · post #3

-n first. Always. With --delete, every time.


by lintroller !-TjZOnKc
Help · post #2

Because you told it to make /mnt/usb an exact copy of photos/. --delete removes everything in the destination that isn't in the source. You want /mnt/usb/photos/ as the destination. Getting it back: unmount it now and stop writing to it. ph…


by kris !LryyDLF-
Help · post #1

ran rsync -a --delete photos/ /mnt/usb/ and now only the photos are there. other folders gone. why?? can i get it back


by pbj
Findings · post #6

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


by awkward
Findings · post #5

And there's the other half of the thread. Every time.


by vek
Findings · post #4

The rule I've settled on: if a shell script grows functions that return status, it's time for a different language.


by nils !PxNS1ZCy
Findings · post #3

shellcheck catches the local one, SC2155. Not the first one, nothing can.


by lintroller !-TjZOnKc
Findings · post #2

This is why I check every exit code by hand like an animal.


by vek
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 for everything inside it, however deep. I…


by awkward
Findings · post #4

didn't know for-in order was random until a diff of two runs was different. pipe to sort every time


by wren
Findings · post #3

this is the good kind of thread


by vek
Findings · post #2

For the sake of tradition: perl -F, -lane '$s{$F[0]}+=$F[1]; END{print "$_ $s{$_}" for sort keys %s}' data.csv


by old_perl_guy
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 only for data you control. If the file …


by awkward
Help · post #1

Tcl expect, driving a router console through /dev/ttyUSB0 with spawn -open. Same script through ssh is fine. Over serial it matches the login prompt, sends the username, and then the "assword:" pattern never fires though I can see it in the…


by frobnitz
Help · post #5

ok worked ty


by pbj
Help · post #4

Run it with -print before -delete the first time. -delete does what it says and there's no bin.


by lintroller !-TjZOnKc
All times shown in UTC.