RSS feed [root] /weblog /unix /script




login:

password:

title search:




 


Thu Jul 07 15:54:28 GMT 2011

useful example of shell script



xmlwf, need to know if a XML document is well formed? (A configuration file maybe..)
mkfifo is the coolest one. Sure you know how to create a pipeline piping the output of grep to less or maybe even perl.
nl, add number for every line of a file

http://bashcurescancer.com[..]/10-linux-commands-youve-never-used.html

http://www.thegeekstuff.com/2010/11/50-linux-commands/

======================================create real player song list
#!/bin/sh
win_path=C:/tools
linux_path=/mnt/disk/winapp
for file in `find $1 -type f`;
do
if(`/bin/cat $file | grep $win_path`); then echo $file;fi;
done;
/usr/bin/find $MUSIC_SRC -type f -exec /bin/echo file://{} \; > $TMPDIR/tmp.rm
while read i ; do /bin/echo "$RANDOM $i" ; done < $TMPDIR/tmp.rm | /bin/sort -n | /bin/sed 's/^[0-9]* //' > $TMPDIR/tmp1.rm
/bin/cat $TMPDIR/tmp1.rm |/bin/sed -e 's/file:\/\///' >$HOME/mplayer.list
/bin/cat $TMPDIR/tmp1.rm |/bin/grep -vi wma >$HOME/real.rm
/bin/cat $TMPDIR/tmp1.rm |/bin/sed -e 's/file:\/\/\/var\/www\/html/http:\/\/www.carfield.com.hk/'>/var/www/html/.secure/media/music/live.rm

======================================remove log
for file in `find -type f|grep website.|grep -v lck`;do rm -f $file;done
======================================for loop
for((a = 1; a <10; a++)); do wget -b "http://www.thai.net/ferrari545/bbs_series/ku_bbs_000$a.jpg";done
======================================resize photo
for i in *.jpg; do convert -geometry 1024x768 $i newdir/$i ; done
======================================basic calculation
i=1;find|grep -v zng|grep -v avi|while read file;do mv "$file" $i.jpg;i=$((i+1));done
======================================# Make 3 a copy of 1 (stdout)
exec 3>&1
result="$(command to generate stream \
| tee /dev/fd/3 \
| command to process stream)"
# Now work with $result
# The original stream also went to the console

http://binkley.blogspot.com[..]5/getting-more-from-streams-in-bash.html



(google search) (amazon search)
second
download zip of files only