96,599 reputation
12114239
bio website
location European Union
age
visits member for 2 years, 4 months
seen 28 mins ago

Nov
22
comment How to get execution time of a script effectively?
Beware that running that python command in a subshell and reading its output will take several millions of nanoseconds on most current systems. Same for running date.
Nov
22
comment How to grep for something that's in an environment variable and has a forward slash?
It doesn't make sense for $PWD to be treated as a regex here. So, that should be grep -F -- "$PWD/" file or awk 'index($0, ENVIRON["PWD"])'
Nov
22
revised How to grep for something that's in an environment variable and has a forward slash?
added 139 characters in body
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.