5,684 reputation
636
bio website l0b0.wordpress.com
location Zurich, Switzerland
age 33
visits member for 2 years, 4 months
seen yesterday
stats profile views 296

Developer - Hobby & work


2d
comment Easy way to parse syslog date format
One-liner replacing the date: sudo perl -n -e 'use DateTime::Format::Strptime; my $parser = DateTime::Format::Strptime->new( pattern => "%B %d %Y"); m/^(\w+ \d+ )(.*)/; print ($parser->parse_datetime("$1" . DateTime->now->year)->ymd, " ", $2, "\n");' /var/log/syslog
2d
comment Easy way to parse syslog date format
Zero padding didn't work here.
2d
comment Easy way to parse syslog date format
Don't you want may in there? ;)
2d
revised Is grandchild process also child process?
added 7 characters in body
May
22
comment How to get name of Display Manager on Linux?
You can try [xwininfo -id $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')][1] for the current window. [1]: askubuntu.com/a/20534/10371
May
22
revised Is grandchild process also child process?
added 63 characters in body
May
22
revised Is grandchild process also child process?
added 453 characters in body
May
22
answered Is grandchild process also child process?
May
22
comment TAB autocomplete on sudo sh
Please clarify whether you mean after you typed sudo sh and pressed TAB, or executed sudo sh and pressed TAB (sh may not load autocomplete configuration when starting).
May
19
revised Number of files containing a given string
added 1 characters in body
May
16
comment What is the difference between “sort -u” and “sort | uniq”?
+0.49 for a useful answer, but I would phrase it something like "The output of sort -u can't be passed to uniq to use some of the latter's useful options, such as skipping fields for comparison and counting the number of repetitions."
May
16
revised What is the difference between “sort -u” and “sort | uniq”?
There's no `-uniq` option with a single dash
May
16
comment POSIX head and tail not feature equivalent
@cjm I forgot about non-seekable streams :) I still can't believe excluding the last N lines is much more rare than excluding the first N lines. I'd upvote your answer if it wasn't for the first paragraph and the caveat about seekable streams.
May
15
comment POSIX head and tail not feature equivalent
I highly doubt any implementation of head or tail actually stores the lines; it would simply have to store the position in the file. As you say, starting from EOF, look backwards to find the Nth newline. Record the position and print the entire file until that position. Not exactly resource intensive: time head -n +10 [88 MB file on a harddisk] reports 0.002s. And who's to say whether a feature is "worth implementing?"
May
15
revised POSIX head and tail not feature equivalent
added 47 characters in body
May
15
asked POSIX head and tail not feature equivalent
May
15
comment How to obtain inverse behavior for `tail` and `head`?
head -n -2 is not POSIX compatible.
May
15
comment Is there a general command to see what shell is running?
@jillagre Strange, the standard allows (and mentions) both syntaxes. So -n -1 and -n 1 are equivalent, while -n +1 is not. Bizarre.
May
15
revised How to monitor the last PID assigned by the kernel?
edited tags
May
15
comment Possible sftp connection behind a router that is impossible to open any public ports except some standart ports like http?
Any specific reason to use sftp instead of scp or rsync? Also, please clarify the sentences - it's difficult to read now.