Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
tips:threelinestip [2008/09/22 17:38]
a
tips:threelinestip [2008/12/09 17:23]
a + Local/remote webserver
Line 65: Line 65:
    # strings `which sshd` | grep -i libwrap    # strings `which sshd` | grep -i libwrap
  
 +
 +===== Comparing files & taking some action based on outcome =====
 +**Method 1**
 +<code>
 +cmp -s file1 file2 || {
 +  # do something
 +}
 +</code>
 +**Method 2**
 +<code>
 +cmp -s file1 file2
 +if [ $? = 1 ]
 +then
 +  # do something
 +fi
 +</code>
 +
 +===== IPv4 parsing / sorting =====
 +
 +   egrep '([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}'
 +
 +and
 +
 +   sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4
 +
 + 
 +
 +===== finding a string in a "live" stream =====
 +
 +tail -f filename |grep --line-buffered  STRING
 +
 +===== Local/remote webserver =====
 +
 +Serve files on port 8080 for anybody from the directory from where you start this command: 
 +
 +<code bash|>
 +:;while [ $? -eq 0 ];do nc -vlp 8080 -c'(r=read;e=echo;$r a b c;z=$r;while [ ${#z} -gt 2 ];do $r z;done;f=`$e $b|sed 's/[^a-z0-9_.-]//gi'`;h="HTTP/1.0";o="$h 200 OK\r\n";c="Content";if [ -z $f ];then($e $o;ls|(while $r n;do if [ -f "$n" ]; then $e "<a href=\"/$n\">`ls -gh $n`
 +";fi;done););elif [ -f $f ];then $e "$o$c-Type: `file -ib $f`\n$c-Length: `stat -c%s $f`";$e;cat $f;else $e -e "$h 404 Not Found\n\n404\n";fi)';done
 +</code>
  
tips/threelinestip.txt · Last modified: 2015/01/07 07:47 by mrizvic
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready