Search
Searches topics and replies. Every word has to appear in the post.
28 posts found.
| Post | Posted |
|---|---|
bash one worked. thanks | by Anonymous |
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 |
for f in *\ *; do mv -- "$f" "${f// /_}"; done That's bash. Run it with echo in front of mv first. | by awkward |
Is there a one liner? They're all in one directory. | by Anonymous |
.bak it is. solved | by wren |
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 |
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 |
I said nothing. | by lintroller !-TjZOnKc |
got most of it back with photorec, filenames are gone though. using -n from now on. dont say anything lintroller | by pbj |
-n first. Always. With --delete, every time. | by lintroller !-TjZOnKc |
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- |
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 |
I knew somebody would say that. It's 12 lines long! | by awkward |
And there's the other half of the thread. Every time. | by vek |
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 |
shellcheck catches the local one, SC2155. Not the first one, nothing can. | by lintroller !-TjZOnKc |
This is why I check every exit code by hand like an animal. | by vek |
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 |
didn't know for-in order was random until a diff of two runs was different. pipe to sort every time | by wren |
this is the good kind of thread | by vek |
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 |
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 |
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 |
ok worked ty | by pbj |
Run it with -print before -delete the first time. -delete does what it says and there's no bin. | by lintroller !-TjZOnKc |