Chinaunix首页 | 论坛 | 博客
  • 博客访问: 532540
  • 博文数量: 119
  • 博客积分: 3167
  • 博客等级: 中校
  • 技术积分: 1215
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-20 21:21
文章分类

全部博文(119)

文章存档

2015年(21)

2012年(4)

2011年(1)

2007年(11)

2006年(50)

2005年(32)

分类: LINUX

2005-12-23 21:06:30

shell编程 3-6章

输入与输出 echo的使用 -e 打开特殊字符的转义功能 c 不换行 f 进纸 TAB 换行 当前行打印 echo -n 不换行 echo "string" string 使用单引号和双引号的区别 read的使用 echo -n "input your name:" && read name read -p "input your name:" name read -t 10 name #timeout read -a name #read into an array read -n 1 res read -s #不在控制台显示 类似密码输入 cat tac rev cat 1. cat file > file2 2. 使用cat得到特殊字符的ASCII码 有的不能显示 showkey -a 10进制 8进制 16进制 3. cat > file << eof 4. cat < eof 可以制作说明或者菜单 5 cat < sth 与 cat << sth 的区别 cat < file #显示file的内容 与 cat file输出相同 cat << sth #表示遇到sth退出cat 管道 tee ls > filename ls | tee filename 重定向 0 标准输入 1 标准输出 2 标准错误输出 ls xxx > file 如果ls xxx返回为0 , 那么标准输出写到file 如果ls xxx返回不为0 , 那么标准错误输出不会写到file 希望 错误输出和标准输出都写到file ls xxx 1>file # 不能有空格 , 同ls xxx > file ls xxx 2>file # 错误输出写入file ls xxx > file 2>&1 # 错误输出和标准输出重定向到file #把一个文件作为一个命令的输入 ls > file ls -l < file ls -l < file > file2 << delimiter # 从标准输入中读入 直到遇到delimiter command <&m # 把文件描述符m作为标准输入 command >&m # 把标准输出重定向到描述符m command <&- # 关闭标准输入 命令的执行顺序 && test -e z && echo "z exist...." test -e x && echo "x exist...." test -e z || echo "run" test -e x || echo "run" test -e x && echo "run 1" || echo "run 2" test -e z && echo "run 1" || echo "run 2" .和source 当前shell执行 bash 新建一个shell执行 () 子shell执行()里面的命令 {} 子shell执行 但是 一般用于函数 fun() { exit 1 }

阅读(1260) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~