Posts

Showing posts with the label shell script

BASH scripting TIP #1

In bash script file $? - store exit value of last command that was executed $* - store all args "$@" - store all args, individually with qoute "$1", "$2" $1 - first arg $2 - second arg $n - nth arg

The combination of xargs

Assume that you : Have folder "mylist" that contain a lot of files such as "a.php", "uud.php", "ad.py".... You want to : Add new extension ".du" to any files in this folder I can do : ~/mylist$ ls | xargs -I f mv f f.du             # god bless -I :o Or I can do : ~/mylist$ find . -name '*.py' | xargs -I f mv f f.du        # just add new extension for *.py * aha , i think that a lot of combination could made :) ** next time, it should be rename extension not add it. (my eng is suck)