shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言
特别感谢作者:sjqu兄
这就是我的一个练习,请多指教。
代码:
#!/bin/bash
#bakup /etc/fstab
cp /etc/fstab /etc/fstab.orig
# config
fdisk -l /dev/hda |grep FAT >>temp
fdisk -l /dev/hdb |grep FAT >>temp
fdisk -l /dev/hdc |grep FAT >>temp
fdisk -l /dev/hdd |grep FAT >>temp
#sort
awk '$0~/\*/ {print $1" "$NF}' temp >>pt
awk '$0!~/\*/ {print $1" "$NF}' temp >>pt
i=142
while read disks fstype
do
if [ $fstype = "FAT32" ]; then
disks_FS=vfat
else
disks_FS=msdos
fi
i=`expr $i + 1`
if [ "${i:2}" != "8" -a "${i:2}" != "9" ]; then
echo -e "$disks"\\t"/mnt/"\\$i""\\t"$disks_FS"\\t"iocharset=gb2312,codepage=936,umask=0 0 0" >>/etc/fstab
fi
done <pt
rm -f temp pt