Skip to content

Instantly share code, notes, and snippets.

@nobucshirai
Last active December 26, 2015 12:29
Show Gist options
  • Save nobucshirai/7151864 to your computer and use it in GitHub Desktop.
Save nobucshirai/7151864 to your computer and use it in GitHub Desktop.
A wapper script of cp. Copy files to temporary directory of current directory.
#!/bin/bash
# $Id: box_cp.sh,v 1.2 2013-10-25 21:30:26+09 shirai Exp shirai $
main(){
ArgCheck $@
BoxMaker
diae cp -av ${file_list[@]} ${box_dir}
}
ArgCheck(){
Ind=0
file_list=()
for file in $@; do
((Ind++))
if [[ $Ind != $# ]] ;then
file_list=(${file_list[@]} $file)
else
dir_path=$file
fi
done
}
BoxMaker(){
box_dir="${dir_path}/_box"
if [ ! -e $box_dir ];then
mkdir $box_dir
else
box_dir="${dir_path}_box_${RANDOM}"
if [ ! -e $box_dir ];then
mkdir $box_dir
else
echo " mkdir $box_dir was failed."
exit
fi
fi
}
diae(){
echo $@
$@
}
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment