Reputation
675
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
5 22
Impact
~28k people reached

Jun
27
comment Decoding URL encoding (percent encoding)
Great solution. And even shorter and smarter: ... | sed 's/+/ /g;s/%\(..\)/\\\\x\1/g'. The -e option can be omitted here in fact...
Jun
27
comment Decoding URL encoding (percent encoding)
awk: As this makes use of a library function, chr(), there is a high probability it will solely work on GNU awk (gawk). However, in this case there will be hardly any equivalent for POSIX awk, because the -n option (allowing non-decimal arguments) IS a GNU awk specialty.
Jun
25
comment How can I find broken symlinks
Yet another shorthand for those whose find command does not support xtype can be derived from this: find . type l -printf "%Y %p\n" | grep -w '^N'. As andy beat me to it with the same (basic) idea in his script, I was reluctant to write it as separate answer. :)
Jun
24
comment Any CLI to validate URL?
Even wget can do that to a certain extent (wish I could write an answer here, but the ever-present SE "cerberuses" have chosen to close this question). * Sigh * So here goes ... You may (mis)use wget -nv --spider <someURL> and evaluate its return code (echo $?). This is only for checking whether the link is valid (respectively the server still up) or not, though.
Jun
24
comment “wget --restrict-file-names=windows” seems to fail converting links for NTFS
@slm Small typo sighted: must be --restric**t** ... Unfortunately due to the (IMO most idiotic) rule on SE that you may only fix typos if you also edit something else (>=6 char limit), I can't fix it myself, as there is really nothing else that needs to be altered.
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
It's in fact the other way round. I DO NOT expect data with * or - as first character, but the shorter expression will allow this (and I can't permit that ;)) IOW, the shorter one is too liberal and data which should be filtered out will be shown.
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
Thanks, also for the info about \s. Well, I wanted to support both tabulators (et al.) and "plain" spaces, hence I used \s on purpose. However, I wasn't aware that this is not part of ERE. Most peculiar...
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
Note that \s* stands for various whitespace like e. g. tabulators as well. Your shorter solution blindly assumes that whitespace = space, which is a little naughty ;) Plus, whatever you write into [ ] is arbitrary in order, whilst my expression dictates a definite order - for a reason! Your expression would even allow a * or - as first characters, which is plainly wrong, as they are arithmetic operators and must be preceded by a number. Shorter is not always better, as it may unwantedly alter the logic.
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
"but you can consume the expressions and see if the result is empty" * GASP * Eh? That sed approach is a dirty hack. As Costas shows in the other answer, it can be done with pattern matching - there was just a tiny nudge into the right direction that I was missing. :)
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
SO simple? Just putting the ^ at the beginning did the trick. Thank you very much! (also for not inverting the logic for no reason ;)) Again: single numbers must work as well as numbers with addends. So it is not that simple as replacing * by +.
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
@ikrabbe It definitely doesn't. :) So I now get it, you were the initiator of inverting the logic, and user179... just jumped on the bandwagon. LOL.
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
@ user1794469 No. Doesn't help me at all. By replacing && by ||, you've just inverted the logic. Coolish. But that's totally pointless, as I need the result of the expression itself, not the result if the expression is false.
Jun
23
comment Shell pattern matching and arithmetic operators (+ - * / %)
Thanks, but it's meant to be that way. :) It should match on "1234" as well as "2345*6789*4321", or in prose, on single numbers as well as on "formulae" (i. e. additions in this case). However, the problem is that it matches also on additions + and divisions /, even though I'm only allowing subtractions and multiplications in this sample one-liner. Your answer will also exclude standalone numbers, as now you do no longer allow that the addend be omitted.
Jun
19
comment Delete lines containing repeated text
Though untested, your (elegant!) solution should also work in non-GNU sed when written like this: sed '/\(\S\+\)\s\1/d' file. Just a little more escaping needed, and you'll be 100% compatible everywhere.
Jun
19
comment Print everything between two patterns, then delete first and last line of the resulting output
Thanks. :) Upvote done now, since you've begged for it. See, you got 20k rep, so my upvote is just like a water drop in a big sea. You can't be serious to require my upvote to be happy. ;-) With 20k, you've achieved everything imaginable that can be achieved on this site. I would accept tens of downvotes per week should I ever get to enter this rep zone...I'd just not care anymore.
Jun
19
comment Print everything between two patterns, then delete first and last line of the resulting output
Heh, never do that. A cup of coffee always works wonders (at least for me). :P
Jun
18
comment Print everything between two patterns, then delete first and last line of the resulting output
Great update, Mike. Good work.
Jun
18
comment Print everything between two patterns, then delete first and last line of the resulting output
To begin with, I have no idea why you're always referring to red and green...is this some allusion to sports which I don't get perhaps? ;) Or to a traffic light? Symbolism is great, but it's always hard to grasp without explaining the symbols first... P.S. Nevertheless, the downvote is not from me.
Jun
18
comment Print everything between two patterns, then delete first and last line of the resulting output
Congrats, you've just gained a 50 percent clarity boost with the update of your answer. :) Looks near-perfect now, well done. (Those freaking GNU-isms every time, grrrr. :-@)
Jun
18
comment Print everything between two patterns, then delete first and last line of the resulting output
"because those lines are already excluded by the /start_data/,/end_data/ range" Nope, in fact they are NOT. sed -n '/start_data/,/end_data/p' myfile WILL print both start_data and end_data patterns, each on their own line (first/last). If you don't believe me, try it out. :)