96,679 reputation
12114239
bio website
location European Union
age
visits member for 2 years, 4 months
seen 10 hours ago

Nov
21
comment Group by and sum in shell script without awk
On Solaris, use nawk or /usr/xpg4/bin/awk, or add a PATH=`getconf PATH`:$PATH as the one in /bin is an ancient non-standard one.
Nov
21
reviewed Approve Group by and sum in shell script without awk
Nov
21
comment sort command in unix with numeric sort
@KasiyA -k defines a sort key. See the man page for details. -k2n defines a sort key starting at the second field and ending at the end of the line and makes it a numeric sort key.
Nov
21
comment get first X characters from the cat command?
The ${var:offset:length} construct you're using here actually comes from ksh93 and is also supported by recent versions of zsh (zsh has its own $testString[1,50]). You need ${testString:0:50} in ksh93 and zsh however.
Nov
21
comment get first X characters from the cat command?
That also assumes $filename or $testString doesn't contain blank newline or wildcards or start with -.
Nov
21
comment get first X characters from the cat command?
Strictly speaking, that does one read() of 50 bytes. If the file is a pipe for instance and fewer characters are available at the time, then fewer bytes will be returned. To have the equivalent of head -c50, you'd need to use the GNU specific iflag=fullblock.
Nov
21
comment sort command in unix with numeric sort
That's still for sorting numerical values, the difference with -n is that it's not limited to decimal integers. That would still sort "$lvl=17" before "$lvl=2" as part of the last-resort sorting.
Nov
21
comment sort command in unix with numeric sort
To paraphrase, -n and -g are redundant here as the input is not numerical. So this answer is misleading, hence the downvote (also note that -g and the long options are GNU specific).
Nov
21
answered sort command in unix with numeric sort
Nov
21
comment sort command in unix with numeric sort
No, all those lines have the same ranking with sort -n since they don't start with a number. The reason it sorts them is the last-resort full-line sort (lexically, not numerically) done for lines with the same ranking. That would sort "$lvl=17" before "$lvl=2".
Nov
21
revised sort command in unix with numeric sort
added 18 characters in body
Nov
20
answered How to read from a named pipe after the writer process exits?
Nov
20
revised Negative arguments to head / tail
added 147 characters in body
Nov
20
answered Negative arguments to head / tail
Nov
20
comment Negative arguments to head / tail
See POSIX head and tail not feature equivalent
Nov
20
comment Shorter command for deleting files
While the original code in the question is completely flawed from a security point of view, yours also is as it's similar for instance to CVE-2011-0441.
Nov
20
revised Suppress 'file truncated' messages when using tail
added 78 characters in body
Nov
20
answered Suppress 'file truncated' messages when using tail
Nov
20
comment od: Put offset n to n of a hexdump to a file in proper hexdump -C (hex+ASCII) format
hexdump has -s -n for od's -j and -n.
Nov
20
comment od: Put offset n to n of a hexdump to a file in proper hexdump -C (hex+ASCII) format
You're running grep -bo on strings applied to a hex dump?! And then want to run od on the hex dump!? Are you sure you don't mean grep -bo XXXX blah and od -j... blah?