СµÜµÚÒ»´Î½Ó´¥SHELL £¬Çó½â
дSHELL³Ì¹Òµ½LINUXϵͳÉÏ¡£È»ºóÔÚдһ¸öÍê³ÉºóÐ¶ÔØ¡£
:p welcome to shell@linuxeden :)
ΪÁ˱ãÓÚÄú¸üºÃµÄÀûÓñ¾ÂÛ̳, ·¢ÌûǰÇëÏÈä¯ÀÀһϱ¾°æÖö¥µÄ¼¸¸öÌû×Ó ²»ÖªËùÔÆ......
²»¹ý¿´µ½Ð¶ÔØÁ½¸ö×Ö
ËÆºõÊÇÓÐ¹Ø mount, umountµÄ
¿É²Î¿¼ÎÒÕâÆª¿´¿´
[url]http://www.linuxeden.com/forum/showthread.php?t=154178[/url]
¶Ô¶þÂ¥µÄÌû×ÓÒªÈÏÕæÁì»áÆä¾«Éñ£¬Îû ;) ÓÖ¿¿²Â! û°ì·¨Ñ½
dearvoidÔÙÈýÇ¿µ÷Öö¥/¾«»ªÌû
´ó»ï¾ÍÊDz»Àí [0 No.2053 huan@huan ~/svn_bash/running]$ cat mynce.sh
#! /bin/bash
# set -n
# set -x
# where to copy to
dst="/media/usb"
# where to copy from
src="/home/huan/study/nce3/"
# default device to copy to
dev=/dev/sda1
# run as root to use mount/umount, not a good idea :)
if (( $(id -u) != 0 )); then
sudo $0 "$@"
exit $?
fi
copy(){
for file in $*;do
if [[ ! -f $src/lesson${file}.mp3 ]];then
echo "Can not find \"$src/lesson${file}.mp3\", skipped."
continue
fi
if [[ -f $dst/lesson${file}.mp3 ]];then
rm $dst/lesson${file}.mp3
fi
# copy each files ten times
for((i=1;i<=10;i++))do
cat $src/lesson${file}.mp3 >> $dst/lesson${file}.mp3
done
done
#echo "Done."
}
usage(){
echo "$(basename $0) [ -d device ] [ files_to_copy ]"
exit 0
}
if [[ $1 == '-d' ]]; then
shift
dev="$1"
shift
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]];then
usage
fi
# check if it's a block dev
if [[ ! -b $dev ]]; then
echo "$dev not a block device"
exit 1
fi
# if not mounted, try to mount
if ! mount | fgrep -q "$dev" ;then
[[ -d $dst ]] || mkdir $dst
if ! mount $dev $dst -o iocharset=utf8; then
echo "Can not mount $dev --> $dst, aborting ..."
rmdir $dst
exit 127
fi
# mounted, get the mountpoint
else
dst=$( mount | fgrep "$dev" | awk '{ print $3 }')
fi
rm $dst/lesson* 2> /dev/null
if [[ $1 == '' ]];then
# ask what to copy
read -p "lesson[s] to copy: " LESSON
echo "This will take a little time, please be patient ..."
copy $LESSON
else
copy $@
fi
# umount device after copying
if umount $dst 2>/dev/null;then
echo "Done"
else
echo "$dst busy now, will be umounted if the device not used any more ..."
umount -l $dst
fi
´ÓÌáʾusageÀ´¿´£¬Õâ¸ö½Å±¾ÊÇ3ÖÖ·½Ê½À´¿½±´mp3£¬Í¨¹ý³ÌÐòÖеÄÌõ¼þÓï¾ä£¬ÔÙ¼ÓÉÏÐ©ÌØÊâ±äÁ¿ÓëÑ»·À´ÊµÏÖ¹¦ÄÜ~ºÜ²»´íµÄ¡£²»¹ý£¬ÎÒ¾ÍÊÇÔÚµÚÒ»²¿·ÖÅжÏÓû§Éí·ÝÖУ¬Ê¹ÓÃsudoÃüÁÄǸöÆðʲô×÷Ó㬲»Ì«Ã÷°×£¬Ò²Ï£Íû£¬Ã÷°×µÄ´ó¸ç£¬´ó½ãÃÇ£¬°ï½â´ð¡£Ð¡µÜQQ£º383088680
лл~ sudo ÊÇʹÓÃrootȨÏÞÀ´Ö´ÐÐÕâ¸ö½Å±¾
Èç¹ûÓû§±»ÔÊÐíµÄ»°
µ±È»£¬²»ÊÇÿ¸ö·¢ÐаæÖж¼»á°²×°²¢ÍƼösudo ¹À¼ÆÍ·Ð÷»¹²»ÊǺÜÇåÎú°É ȷʵ²»ÖªµÀÒª×öʲô¹þ¹þ
Ò³:
[1]