exec 2>&-
n<&-
n>&-
0<&-, <&-
1>&-, >&-
2>&-
To move all files, even with weird special characters in the filename, to another directory do this:
$ find . -print0 | xargs --null mv --target-dir=<DIRECTORY>
command > file 2>&1
For this to work the file ~/.bash_profile must be modified to enable the line source ~/.bashrc.
TEMP=`getopt -o c --long complete -n "$0" -- "$@"`
if [ $? != 0 ]; then
echo "Syntax error." >&2
exit 1
fi
eval set -- "$TEMP"
while true; do
case "${1}" in
-c|--complete)
DO_IT_HERE
;;
--) # finished parsing options
shift
break
;;
*)
echo "Internal error." >&2
exit 1
;;
esac
shift
done
This piece of code is espcially useful when expanding path information in bash scripts like $PATH or $LD_LIBRARY_PATH:
FOO=${FOO+$FOO:}/usr/local/lib
Given the variable foo=/tmp/my.dir/filename.tar.gz, we can use these expressions:
To split a string, use this expression:
$ set -- $(IFS=":"; echo ${VARIABLE})
Afterwards, $1, $2, … contain the splitted values.
When the “smart” bash completion gets in your way you can completely remove all functions by
complete -r
To see a short help try
help complete