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/11/26 09:04]
greebo
tips:threelinestip [2009/05/25 00:34]
127.0.0.1 external edit
Line 64: Line 64:
  
    # strings `which sshd` | grep -i libwrap    # strings `which sshd` | grep -i libwrap
 +
  
 ===== Comparing files & taking some action based on outcome ===== ===== Comparing files & taking some action based on outcome =====
Line 81: Line 82:
 </code> </code>
  
 +===== IPv4 parsing / sorting =====
  
-=== finding a string in a "live" stream ===+   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 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>
 +
 +
 +===== resolving IP Addresse (nmap) =====
 +
 +<code bash|>
 +nmap -sL $1 2>/dev/null |
 +perl -ne 'print unless /^Host [\d.]+ /' |
 +grep 'not scanned' |
 +cut -d ' ' -f 2,3 |
 +sed -e 's/\(.*\) (\(.*\))/\2 resolves to \1/'
 +</code>
 +
 +output:
 +<code>
 +198.133.219.10 resolves to fed.cisco.com
 +198.133.219.11 resolves to asp-web-sj-1.cisco.com
 +198.133.219.12 resolves to asp-web-sj-2.cisco.com
 +198.133.219.13 resolves to fedtst.cisco.com
 +198.133.219.14 resolves to www.netimpactstudy.com
 +198.133.219.15 resolves to deployx-sj.cisco.com
 +198.133.219.16 resolves to contact-sj1.cisco.com
 +198.133.219.17 resolves to scc-sj-1.cisco.com
 +198.133.219.18 resolves to scc-sj-2.cisco.com
 +198.133.219.19 resolves to scc-sj-3.cisco.com
 +198.133.219.20 resolves to jmckerna-test.cisco.com
 +198.133.219.21 resolves to events.cisco.com
 +198.133.219.22 resolves to bam-prod-1.cisco.com
 +198.133.219.23 resolves to redirect.cisco.com
 +198.133.219.25 resolves to www.cisco.com
 +198.133.219.26 resolves to partners.cisco.com
 +</code>
 +
 +
 +===== Linux Get Hardware Serial Number From Command Line  =====
 +   dmidecode |grep -i serial
 +
 +===== Convert pdf to jpg =====
 +
 +  for file in `ls *.pdf`; do convert -verbose -colorspace RGB -resize 800 -interlace none \
 +    -density 300 -quality 80 $file `echo $file | sed 's/\.pdf$/\.jpg/'`; done
 +
 +
 +
 +
 +
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