如某当前目录存在以下文件或目录: 1.txt 2.txt 3.txt dir1 dir2 my2015.tar my2016.tar 若要对当前目录除1.txt 和dir1、tar外,打包tar 步骤一、建立excludefile.txt文件,录入排除的文件内容,可用以下命令: 如: touch 1.txt>excludefile.txt touch dir1>>excludefile.txt touch my2015.tar>>excludefile.txt touch my2016.tar>>excludefile.txt touch excludefile.txt>>excludefile.txt 或者 ls | grep -w 1.txt>excludefile.txt ls | grep -w dir1>>excludefile.txt ls | grep -e tar >>excludefile.txt ls | grep -w excludefile.txt>>excludefile.txt tar cvfX test.tar excludefile.txt * 或者 tar -cvf test.tar -X excludefile.txt * 若*改为.,则excludefile.txt中排除的路径就要做相应修改,如:./1.txt