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
bash [2009/01/05 19:35]
a
bash [2009/01/14 10:30]
a
Line 1: Line 1:
-If you just want to find out what's new in a directory:+===== .barshrc =====
  
-lsnew() { ls -lt ${1+"$@"head -20; }+<code |f .barshrc>
  
-**.barshrc** 
- 
-<code bash|> 
 function os { function os {
       export OPER_SYS_1="`uname -s`"       export OPER_SYS_1="`uname -s`"
Line 13: Line 10:
       echo -e "\033[32mKernel:\033[0m $KERN_INFO"       echo -e "\033[32mKernel:\033[0m $KERN_INFO"
       }       }
-</code> 
  
-<code bash|> 
 function hw () { function hw () {
    export MOBO_MAN="`sudo dmidecode --type baseboard | grep 'Manufacturer' | cut -d' ' -f2-`"    export MOBO_MAN="`sudo dmidecode --type baseboard | grep 'Manufacturer' | cut -d' ' -f2-`"
Line 35: Line 30:
  
     alias system="os &amp;&amp; hw"     alias system="os &amp;&amp; hw"
 +
 +==== If you just want to find out what's new in a directory ====
 +
 +   lsnew() { ls -lt ${1+"$@"} | head -20; }
 +
 +===== Scripts =====
 +==== Diff Two Directories ====
 +
 +<code bash|f diff2.sh>
 +#!/bin/bash
 +
 +cr='*'
 +if [ -z $3 ]; then cr=$3; fi
 +
 +for f in `find $1/$3 -type f | sed "s|$1/||"`
 +do
 +  printf "===!%-76s" "$f!" | tr ' !' '= '; echo
 +  diff $1/$f $2/$f | sed -e "s/^</$1: /" -e "s/^>/$2: /"
 +done
 +</code>
 +
 +===== Bash misc stuff =====
 +==== $RANDOM not random at all ====
 +
 +instead of $RANDOM use ..
 +  SEED=$(head -c4 /dev/urandom | od -t u4 | awk '{ print $2 }')
 +  ((N=SEED%N))
 +or
 +
 +  SEED=$(head -1 /dev/urandom | od -N 1 | awk '{ print $2 }'
 +  ((N=SEED%N))
 +
 +
 +
bash.txt ยท Last modified: 2009/05/25 00:35 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready