线上班第六期_shell 基础_20180422

把答案贴到回帖里

命令参考

1000  a=1
 1001  echo $a
 1002  a=
 1003  a="seveniruby testerhome"
 1004  echo $a
 1005  echo ${a}
 1006  echo $a
 1007  echo $ab
 1008  echo ${a}b
 1009  echo $PWD
 1010  for((i=0; i<10; i++)); do echo $i;echo $i;done
 1011  if [ -f json.schema ] ; then echo is file; else  echo not file; fi
 1012  ls
 1013  array=(1 2 3 4 5)
 1014  for f in ${array[*]}; echo $f
 1015  for f in ${array[*]}; do echo $f; done
 1016  ss="aa bb cc dd";for x in $ss;do echo $x ;done
 1017  ss="aa bb cc dd";for x in "$ss";do echo $x ;done
 1018  i=0
 1019  while [ $i -lt 5 ] ; do echo $i;done
 1020  while [ $i -lt 5 ] ; do echo $i; ((i=i+1)); done
 1021  ls
 1022  vi /tmp/file1
 1023  while read line;do echo $line;done < /tmp/file1
 1024  while read line;do echo will $line;done < /tmp/file1
 1025  if ls dddd;then echo exist ; else not exist; fi
 1026  ls ddd
 1027  echo $?
 1028  sleep 1
 1029  sleep 2
 1030  sleep 200
 1031  sleep 200 &
 1032  echo $!
 1033  cat /tmp/file1
 1034  read x < /tmp/file1
 1035  echo $x
 1036  read x
 1037  read line < /tmp/file1
 1038  echo $line
 1039  echo testerhome > /tmp/file2
 1040  cat /tmp/file2
 1041  echo testerhome >> /tmp/file2
 1042  cat /tmp/file2
 1043  echo testerhome > /tmp/file2
 1044  cat /tmp/file2
 1045  echo testerhome
 1046  printf "xxx"
 1047  echo xxx
 1048  cat /tmp/file2
 1049  printf "xxxxx" >> /tmp/file2
 1050  cat /tmp/file2
 1051  printf "ddddddd" >> /tmp/file2
 1052  cat /tmp/file2
 1053  grep
 1054  grep "s*"
 1055  echo "ddddddssssssddddddd"
 1056  echo "ddddddssssssddddddd"  | grep s*
 1057  cat /tmp/file2
 1058  cat /tmp/file2  | grep ddddd
 1059  ls *
 1060  echo *
 1061  echo ?
 1062  echo ??????
 1063  cat /tmp/file2  | grep ddddd
 1064  find_ddd() { cat /tmp/file2 | grep ddddd ; }
 1065  find_ddd
 1066  find_ddd() { cat /tmp/file2 | grep $1 ; }
 1067  find_ddd
 1068  find_ddd ddddd
 1069  find_ddd xx
 1070  find_ddd() { cat $2  | grep $1 ; }
 1071  find_ddd x /tmp/file2
 1072  find_ddd dd  /tmp/file2
 1073  find_ddd dd  /tmp/file1
 1074  find_ddd d  /tmp/file1
 1075  vi /tmp/1.sh
 1076  bash  /tmp/1.sh
 1077  sh   /tmp/1.sh
 1078  /tmp/1.sh
 1079  chmod +x /tmp/1.sh
 1080  /tmp/1.sh
 1081  echo PATH
 1082  echo $PATH
 1083  ls
 1084  which ls
 1085  /usr/bin/ls
 1086  1.sh
 1087  export PATH=$PATH:/tmp/
 1088  1.sh
 1089  vi /tmp/1.sh
 1090  1.sh  ddd
 1091  1.sh x
 1092  vi /tmp/1.sh
 1093  1.sh x
 1094  1.sh ddd
 1095  vi /tmp/1.sh
 1096  echo $a
 1097  a=""
 1098  echo $a
 1099  1.sh ddd
 1100  echo $a
 1101  1.sh ddd
 1102  vi /tmp/1.sh
 1103  1.sh ddd
 1104  echo $a
 1105  source /tmp/1.sh
 1106  source /tmp/1.sh  ddd
 1107  echo $a
 1108  bash /tmp/1.sh  ddd
 1109  /tmp/1.sh  ddd
 1110  source /tmp/1.sh  ddd
 1111  echo $a
 1112  ff
 1113  ff ddd
 1114  . /tmp/1.sh  ddd
 1115  bash -x /tmp/1.sh
 1116  bash -x /tmp/1.sh ddd
 1117  echo $PATH
 1118  export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
 1119  vi ~/.bash_profile
 1120  ls
 1121  pwd
 1122  curl http://www.baidu.com
 1123  curl http://www.baidu.com > /tmp/index.html
 1124   cd /tmp/
 1125  python -m CGIHTTPServer

作业

写一个脚本,第一个参数为目录名,然后遍历目录内所有的文件, 打印每个文件是否是目录还是文件的提示输出。