1、编写个shell脚本将当前目录下大于10K的文件转移到/tmp目录下
!/bin/shcd /home/testfor i in ls -l |awk '{if($5>10240) {print $9}}'do mv $i /tmpdone
2、编写shell脚本获取本机的网络地址。
比如:本机的ip地址是:192.168.100.2/255.255.255.0,那么它的网络地址是
192.168.100.1/255.255.255.0
方法一:
!/bin/bash
This script print ip and network
file="/etc/sysconfig/network-scripts/ifcfg-eth0"
if [ -f $file ] ;then
IP=grep "IPADDR" $file|awk -F"="'{ print $2 }'
MASK=grep "NETMASK" $file|awk-F"=" '{ print $2 }'
echo "$IP/$MASK"
exit 1
fi
方法二:
!/bin/bash
This programm will printf ip/network
IP=ifconfig eth0 |grep 'inet ' |sed's/^.*addr://g'|sed 's/ Bcast.*$//g'
NETMASK=ifconfig eth0 |grep 'inet '|sed's/^.*Mask://g'
echo "$IP/$NETMASK"
exit
3、用Shell编程,判断一文件是不是字符设备文件,如果是将其拷贝到 /dev 目录下。
参考程序:
!/bin/sh
FILENAME=
echo “Input file name:”
read FILENAME
if [ -c "$FILENAME" ]
then
cp $FILENAME /dev
fi
4.请为下列shell程序添加注释,并说明程序的功能和调用方法:
!/bin/sh
/etc/rc.d/rc.httpd
Start/stop/restart the Apache web server.