Reputation
858
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
1 6 27
Impact
~51k people reached

Feb
8
comment Combining strings command and grep: how to limit results to null-terminated strings
As usual, you're simply a magician. :-O Thank you so much. Had not the slightest idea that tr would even understand a whole set like [[:print:]]instead of mere dumb single characters (i. e. the purpose it would normally serve). Might take me a while to have your partially "golfed" solution broken down to things I can follow, but nevermind: I think I can master that on my own. Thanks again.
Feb
8
comment How to get a string between two special characters using Shell?
@StéphaneChazelas I was just as confused as you were...Well, for a starter: when I want a string between two special characters I usually assume that there will be no special character of the same kind in between! So to say, parsing the (silly) string &%asdf$Chris$fdsa?# for "the string between the $" would clearly mean that the result is Chris and, as visible, there is no other $ sign in between. How else could the parser decide?? -- This question ought to be flagged as "too specific" as the technique described in the answers may not be needed elsewhere but in this lone case.
Feb
7
comment Combining strings command and grep: how to limit results to null-terminated strings
@MarkPlotnick Well, actually I thought that if someone posts a solution for '\x00', I can also make this work for, say, '\x07'. Plus, iit was in fact a matter of physical length of question title: now picture something like "Combining strings command and grep: how to limit results to strings terminated by NUL or similar non-printable characters" :-) Ugh. TL;DR. So I chose the most significant case and I am going to adapt similar cases accordingly.
Feb
7
comment Combining strings command and grep: how to limit results to null-terminated strings
@MarkPlotnick Well I always love to be as portable as possible. :) Thanks for the heads-up with -o, as I didn't consider it absolutely necessary. However, if it can eliminate said artifacts, I might include it in the grep options. Besides: I chose the NUL as most common case, but it might indeed be a \x01 in another. So there'd be your control code, all of a sudden! :) That reads, the ideal way would be to find a solution that will work a) without -a and b) for ALL [^[:print:]]
Feb
7
comment Combining strings command and grep: how to limit results to null-terminated strings
@MarkPlotnick Indeed it would, however there appears to be a general problem with \xAA hex codes in the grep regex. Spotted lots of similar questions here on SE. Users occasionally had to work around it by greping for 'XYZ'$'\x00', i. e. using the built-in trickery of some (not all!) shells. Maybe hex codes in grep will only work reliably in GNU grep? Besides: -a is discouraged, as it might wreak havoc on a terminal due to the shell interpreting some of the control codes as actual ones. So these might clear your screen, deface output strings, insult your mother...;-)
Feb
7
comment Combining strings command and grep: how to limit results to null-terminated strings
Sounds like a good idea, but I should see some sample line first instead of blind fiddling. Plus, it would be great to keep using strings, because with big files it will already have filtered so much garbage before grep even gets its first attempt to process the content.
Feb
1
comment How can I get my external IP address in bash?
Got it working with some decent lot of regex magic, but it wasn't easy. Should you insist on using this service, be sure to wrap that line into a script: $ curl -s http://whatismyip.org | grep -o '\([[:digit:]]\{1,3\}\.\)\{3\}[[:digit:]]\{1,3\}'
Feb
1
comment How can I get my external IP address in bash?
+1 Albeit looking so clumsy, this approach has been a life-saver for me too a few times. Because Internet is not WWW. You can have internet access, but you may (commonly in server rooms) be doomed to a non-GUI console, and in this case it's important to remember by heart one of the checkIP service URLs. And as this one is pretty common, it's only seemingly compilcated, as you will be more likely to remember the DynDNS one than the one of amazonaws. That is, if you have NO way to google for it. (not even lynx).
Jan
31
comment Redirecting stdout to a file you don't have write permission on
Well I would be pretty satisfied with 4 :-D Your English is not bad at all. It's just worded in a kind of terse techie nerdspeak. I must guess you're a coder. Coders amongst each other will understand themselves perfectly that way, but a non-coder must think it's worded like...as said.
Jan
29
comment SmartMonTools: How can I know if there is any smartctl test running on my hard disk?
@frostschutz "smartctl -H is a false friend in that regard." You can say that again! I too have fallen for this option once, thinking it might have to do with the self-tests...but no, entirely different subject (and purpose).
Jan
29
comment Redirecting stdout to a file you don't have write permission on
@umeboshi But reliable only if you're experienced enough to know exactly what you're doing. Fordd can be fairly dangerous (if not to say: devastating) if only a slight mistake was made. So for new users, I'd rather recommend the tee method to be on the safe shore.
Jan
29
comment Redirecting stdout to a file you don't have write permission on
This is worded like an Ancient Chinese riddle. Can't see to understand how this got so many upvotes. (hrmph)
Jan
29
comment Emptying a file for root user does not work
Thanks so much! I had one single mistake in my line, and I think I should quote it here so that people are alerted: sudo cp /dev/null > /to/be/truncated/file. I dunno why exactly it spits me out a bash: /to/be/truncated/file: Permission denied but it does. Omit that damn > and it works. D'oh. (Well, in my case, the origins may still date back to my MS-DOS times, where I would frequently use C> type (...) plus the redirection operator >.)
Jan
16
comment How to tell Linux Kernel > 3.0 to completely ignore a failing disk?
You can check for security lock (Linux only) as follows: sudo hdparm -I /dev/sdX(X = a .. z, you have to known the device name of your drive, of course). Look at the last 10 lines of the output. You MUST be able to read NOT locked in one line. The "not" is important! Should it be missing, your drive is locked!!
Jan
16
comment How to tell Linux Kernel > 3.0 to completely ignore a failing disk?
@Rmano Are you kidding me? The system would never ask for a password! Nor would Linux ... ever. It would just behave as if the drive was badly broken (flooding screen with timing errors etc.). I am not talking about an encrypted drive. If you security-lock a hard drive by password (e. g. with hdparm under Linux), it will most likely not operate on Windows at all (probably not even be detected). Until it gets unlocked again (temporarily (UNLOCK) or permanently (DISPWD))
Jan
16
comment How to tell Linux Kernel > 3.0 to completely ignore a failing disk?
@Rmano Joining late to the party, but OK...what you've reported ("error on each an every I/O operation") can even happen with a 100% perfect drive, when ... security locked! Once experienced with hdparm, which, after finishing its --security-erase, does not reliably remove the security lock from the drive after doing its work (unless by a cold reboot). However, after issuing a DISPWD on that drive (system rescue CD), it behaved just greatly and there were no errors. So beware of those drives locked by security password!! At least make sure your SSD drive doesn't have LOCK enabled.
Jan
16
comment How to tell Linux Kernel > 3.0 to completely ignore a failing disk?
Another big thanks goes to the Linux kernel team for speedily including a patch into a stable kernel release, probably helping 10,000 people that way with similar problems.
Dec
16
comment What is the purpose of the lost+found folder in Linux and Unix?
@JohanE You're telling me. However, the actual reason why I posted my comment was because this answer was trying to suggest us to "be thankful" for lost+found. This felt way too hilarious to be true (I sat here with a broad grin), for the ridiculously few times when we're thankful for it can't compete with those when we'd rather be able to cast a "Begone!" spell to this nuisant lo+fo thing.
Nov
25
comment How to count the number of a specific character in each line?
@AmelioVazquez-Reina It cannot work, by design. Translated into human-readable prose, s/[^,,]//g means: find everything that is not a comma and remove it. Note that this is a [^character]construction, which excludes the character following the caret ^. This should explain why your multiple commas are ignored and interpreted as one single one.
Nov
21
comment hexdump: How to suppress offset column in hex mode
Well, this gets even more interesting. Though you said that the -x option triggers the offset column, hexdump appears to use it per default in some cases. That is, if the only argument to hexdumpis the filename, offset column will be displayed too! Yes, without specifying -x. (Just figured that out.)