RSS feed [root] /unix /weblog /script




login:

password:

title search:




 


Wed Feb 03 22:01:04 HKT 2016

script



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

Wed Jun 14 18:34:19 HKT 2017 From /weblog/unix/script

development


A bash debugger - http://bashdb.sourceforge.net/

Really really good tips - http://fahdshariff.blogspot.com.au[..]3/10/shell-scripting-best-practices.html

Style guide - http://www.kfirlavi.com[..]og/2012/11/14/defensive-bash-programming

Script checker - https://www.shellcheck.net/

How to write a shell - https://indradhanush.github.io/blog/writing-a-unix-shell-part-1 https://indradhanush.github.io/blog/writing-a-unix-shell-part-2

(google search) (amazon search)


Fri Apr 01 11:29:26 HKT 2016 From /weblog/unix/script

bash


How to use eval, hash, readonly, shift, getopts, set, unset, let and shopt - http://www.thegeekstuff.com/2010/08/bash-shell-builtin-commands

Sample bash completion

SSH_COMPLETE=( $(cut -f1 -d' ' ~/.ssh/known_hosts |\
tr ',' '\n' |\
sort -u |\
grep -e '[:alpha:]') )
complete -o default -W "${SSH_COMPLETE[*]}" ssh

http://kasparov.skife.org/blog/stuff/starting-a-meme.html

Check history statistic - brianm@binky:~$ history | awk {'print $2'} | sort | uniq -c | sort -k1 -rn | head
164 svn
52 cd
42 ssh
32 sudo
22 git
16 ls
16 for
14 echo
13 man
10 curl
brianm@binky:~$

http://bluebones.net/2008/04/history-meme/

easy way to do "[-h|--help][-n|--name ]" - http://binkley.blogspot.com/2016/03/bash-long-options.html

(google search) (amazon search)



Wed Feb 03 21:57:47 HKT 2016 From /weblog/unix/script

find


An question about how to remove unused package from MacOSX turn out to be an example of "find" command:

http://forums.osxfaq.com/viewtopic.php?p=57887#57887
http://www.osxfaq.com/tips/unix-tricks/week98/tuesday.ws
http://javarevisited.blogspot.com[..]find-command-in-unix-examples-basic.html

File Search tips in Linux - http://discuss.joelonsoftware.com[..]iscussTopicParent=18272&ixDiscussGroup=3

Another search tip, example of find base on time and size, and how to compare with other files - http://viralpatel.net[..]e-useful-unix-file-finding-commands.html

Like search by name, depth, size - http://www.thegeekstuff.com[..]5-practical-linux-find-command-examples/

use 'find' to delete branch of file: http://keithdevens.com/weblog/archive/2005/Jul/05/find.rm

By time - http://www.thegeekstuff.com[..]unix-linux-find-command-examples-part-2/

Use of empty - http://www.thegeekstuff.com[..]010/03/find-empty-directories-and-files/

(google search) (amazon search)


Wed Feb 03 21:55:53 HKT 2016 From /weblog/unix/script

locate


http://www.thegeekstuff.com/2012/03/locate-command-examples/

(google search) (amazon search)



Fri Jun 07 10:04:21 HKT 2013 From /weblog/unix/script

text


10 awk tips - http://www.catonmat.net/blog/ten-awk-tips-tricks-and-pitfalls/

8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR - http://www.thegeekstuff.com[..]iables-fs-ofs-rs-ors-nr-nf-filename-fnr/

Tutorial of text editing commands - http://www.ibm.com[..]works/aix/library/au-unixtext/index.html

wc and nl tutorial - http://www.thegeekstuff.com/2013/02/wc-nl-examples/

tips for uniq, like show only items have duplications - http://www.thegeekstuff.com/2013/05/uniq-command-examples/

Tips of "cat", include display by column and by delimiter - http://www.thegeekstuff.com/2013/06/cut-command-examples/

(google search) (amazon search)


Fri Mar 01 09:25:37 HKT 2013 From /weblog/unix/script

pdf


Convert PDF to set of image as slide show - http://ejohn.org/blog/easy-pdf-sharing/

pdftk, extra pages from one pdf to another pdf - http://linuxcommando.blogspot.com.au[..]2/splitting-up-is-easy-for-pdf-file.html

(google search) (amazon search)


Tue Jan 29 15:55:20 HKT 2013 From /weblog/unix/script

file


Various ways to working with file - http://www.catonmat.net/blog/bash-one-liners-explained-part-one/

Use truncate to pad the file size up - http://www.lainoox.com/truncate-shrink-extend-files/

(google search) (amazon search)


Sun Dec 23 00:56:52 HKT 2012 From /weblog/unix/script

string


http://www.thegeekstuff.com/2010/07/bash-string-manipulation

http://www.thegeekstuff.com/2010/11/strings-command-examples/

http://www.thegeekstuff.com[..]/01/regular-expressions-in-grep-command/

tr, useful string tranformation tool - http://www.thegeekstuff.com/2012/12/linux-tr-command/

(google search) (amazon search)


Wed Jan 25 00:42:37 HKT 2012 From /weblog/unix/script

xdotool


Simulate user input - http://pratyeka.org/fake-x-input/

(google search) (amazon search)


Sat Sep 03 11:37:14 HKT 2011 From /weblog/unix/script

sort


Sort by column - http://javarevisited.blogspot.com[..]/unix-sort-command-example-tutorial.html

(google search) (amazon search)


Thu Aug 25 02:16:44 HKT 2011 From /weblog/unix/script

webserver


Create webserver with nc using bash

http://www.linuxscrew.com[..]07/09/06/web-server-on-bash-in-one-line/
http://paulbuchheit.blogspot.com/2007/04/webserver-in-bash.html

(google search) (amazon search)


Tue Jul 12 01:11:20 HKT 2011 From /weblog/unix/script

loop


http://www.thegeekstuff.com/2011/07/bash-for-loop-examples/

(google search) (amazon search)


Thu Jul 07 23:54:28 HKT 2011 From /weblog/unix/script

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)


Wed Feb 11 18:55:55 HKT 2009 From /weblog/unix/script

test


hint of using test - http://www.ibm.com/developerworks/linux/library/l-bash-test.html http://binkley.blogspot.com/2009/02/speeding-up-cygwin-login.html


(google search) (amazon search)


Thu May 08 14:00:20 HKT 2008 From /weblog/unix/script

date


A working date calculation script

http://www.unix.com[..]s/4870-days-elapsed-between-2-dates.html

(google search) (amazon search)


Fri Jun 16 21:37:41 HKT 2006 From /weblog/unix/script

check exit status



Need to check #? and PIPESTATUS

http://www.mattryall.net/article.cgi?id=247

(google search) (amazon search)


Sun May 28 18:31:46 HKT 2006 From /weblog/unix/script

Batch rename


Script of batch rename at unix system

http://mattfleming.com/node/110
http://stuart.woodward.jp/?p=279

(google search) (amazon search)


Tue Nov 08 14:33:09 HKT 2005 From /weblog/unix/script

Unix KornShell Quick Reference


http://www.maththinking.com/boat/kornShell.html

(google search) (amazon search)


Tue Oct 04 11:58:05 HKT 2005 From /weblog/unix/script

safer rm


A number of tips to make rm command safer

http://www.macosxhints.com[..]le.php?story=20050928082624470&lsrc=osxh

(google search) (amazon search)