96,094 reputation
12113238
bio website
location European Union
age
visits member for 2 years, 3 months
seen 17 mins ago

Nov
21
comment How to prevent `mv` from moving a collection of files into a single regular one?
@syntaxerror. It is a GNUism. POSIXly: find . -name '* 9?.mp3' -exec sh -c 'exec mv "$@" 90/' sh {} +
Nov
21
revised How to prevent `mv` from moving a collection of files into a single regular one?
clarify we're talking of GNU coreutils here.
Nov
21
comment output to file, then use file for input
sort doesn't store the whole file in memory, it's got a buffer with a maximum size as well and resorts to temporary files when that maximum is reached.
Nov
21
answered How do I display a dependency chain from one package to another?
Nov
21
comment Block a certain URL?
@gena2x, that would certainly not be the most reliable. What if one uses http://url_to_block/url_to_block2/url_to_block%33 or http://url_to_block/url_to_block2/./url_to_block3 or send the GET /url_ in one packet and the rest in the next packet? At least a HTTP proxy will see the full data in the TCP stream and will know how to canonize the requests before filtering.
Nov
21
comment how to route traffic on port to ip:port on linux?
Is IP forwarding enabled? sysctl net.ipv4.ip_forward. Does 192.168.0.1 have a route back to the originating clients via your redirecting machine? If not, you'll probably need to SNAT as well.
Nov
21
answered How does moving a unix domain socket enable socat to monitor traffic?
Nov
21
revised How does moving a unix domain socket enable socat to monitor traffic?
edited title
Nov
21
comment Remove backslashes from a text file
You seem to have a non-POSIX implementation of sed (or possibly you're running that command from a non-POSIX shell?). You don't need sed though, tr is enough: tr -d '\\' < P.
Nov
21
comment Block a certain URL?
You need some form of transparent HTTP proxy or deep inspection filtering that is able to understand the HTTP protocol such as snort in inline mode. And even then, it's going to be very difficult (and impossible with shrewd users) to prevent users to find work arounds.
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".