###############################################
greeting="hello world"
i=1;
while test $i -1e 100; do
case $i in
*0) echo "***************">file$i;
*) echo $i>file$i;;
esac
i='expr $i+1'
done
##################################################
case $# in
1) cat>>$1;;
2) cat<$1>>$2;;
*) echo "usage:append[from] to" ;;
esac
#chmod +x myappend
#myappend file1 file2
######################################################
#下面程序实现scan:扫描当前目录下的每一个子目录,并执行用户提交的命令:
d='pwd'
for i in *
do
if test -d $d/$i
then
cd $d/$i
while echo "$i"
trap exit 2
read x
do trap : 2; eval $x;
done
fi
done
########################################################
#下面程序dircmp测试当前目录与指定目录是否含有相同文件数
if test $ -ne 1 then
echo "Usage:dircmp dirname"
exit 1;
else if test !-d $1
echo "\"$1\" is not adirectory"
exit 1
else
this='ls -l|grep '^-'|wc -l'
that='ls -l $1|grep '^-'|wc -l'
if test $this -ne $that then
echo "Current directory and \"$1\" do not match"
else
echo "Current dirctory and \"$1\" have same number of files"
fi
fi
fi
#dircmp abc
# "abc" is not a directory
###########################################################
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
#############################################################
#.bash_profile
#Get the aliases and functions
if [ -f ~/.bashrc ]
then
. ~/.bashrc
fi
#User specific environment and startup programs
#将我们bin目录($home/bin)和当前路径的当前目录加入到环境变量PATH中
PATH=.:$HOME/bin:$PATH
export PATH
#设置环境变量LOGNAME
LOGNAME=$(logname)
export LOGNAME
#设置一个快捷变量
HOST=$(hostname)
export HOST
#设置文件权限的默认umask,umask在创建文件时用来设置文件的默认访问权限
umask 022
#取消对ctrl+d按件的响应,按下ctrl+d后不注消
set -o ignoreeof
#设置默认的编辑器
EDITOR=/usr/bin/vi
#设置MAIL环境变量,当有邮件的时候shell可以通知我们
#MAIL
MAIL=/usr/spool/mail/$LOGNAME
export MAIL
#设置有主机名的提示符
case $LOGNAME in
root) PS1="$HOST #";;
*) PS1="$HOST $";;
esac
PS2='You need to finish inputting . . .'
#定义一些命令的别名
alias cls='clear'
alias dir='ls'
alias copy='cp'
alias rename='mv'
alias md='mkdir'
alias rd='rmdir'
alias deltree='rm -rf'
################################################
objects=*.o
objects :=$(wildcard*.o)
objects :=$(patsubst %.c,%.o,$(wildcard*.c)
foo : $(objects)
cc -o foo $(objects)
phony target(哑/假目标):不对应实际的文件,只是一个目标
.PHONY:clean #如果这行不加,若当前目录下有个clean文件,则make clean 没有动作
clean: #这是phony target
rm *.o temp
阅读(1190) | 评论(0) | 转发(0) |