快速业务通道

Linux基本操作实验(5)

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-03-26
变量名、转义符等,一般用双引号括起来.缺省情况下echo不解释STRING中的转义符,加上-e 才可,缺省情况,echo 自动输出NEWLINE,加上-n 不输出换行符NEWLINE.
Empire CMS,phome.net

[root@windriver-machine shtest]# echo "\007you home is $HOME,you are connected on `tty`"
\007you home is /root,you are connected on /dev/pts/0
[root@windriver-machine shtest]# echo -e "\007you home is $HOME,you are connected on `tty`"
you home is /root,you are connected on /dev/pts/0
[root@windriver-machine shtest]# echo Hello world
Hello world
[root@windriver-machine shtest]# echo "Hello world"
Hello world
[root@windriver-machine shtest]# w
22:36:57 up 87 days, 23:16, 1 user, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
windrive pts/0 :2.0 Sat19 1.00s 0.28s 6.56s gnome-terminal
[root@windriver-machine shtest]# echo -e "Here is a tab\there are two tabs\t\tOK"
Here is a tab here are two tabs OK
[root@windriver-machine shtest]# echo "\"/dev/rmt0\""
"/dev/rmt0"
[root@windriver-machine shtest]# echo "The log files have all been done" >myfile
[root@windriver-machine shtest]# cat myfile
The log files have all been done
[root@windriver-machine shtest]#

【2】read 可以使用read语句从键盘或者文件中的某一行文本中读入信息,并将其赋给一个变量.

[root@windriver-machine shtest]# read -p "How old r u" age
How old r u32
[root@windriver-machine shtest]# echo $age
32
[root@windriver-machine shtest]# read -p "some words?" -a words
some words?I am a boy
[root@windriver-machine shtest]# echo ${word[*]}

[root@windriver-machine shtest]# echo ${words[*]}
I am a boy
[root@windriver-machine shtest]# read -p "Passowrd:" -s passwd
Passowrd:[root@windriver-machine shtest]# echo $passwd

Empire CMS,phome.net

teetesetbpadasdf

[root@windriver-machine shtest]# read -n
-bash: read: -n: option requires an argument
read: usage: read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
[root@windriver-machine shtest]# read -t 5 auth
sdfasdfas
[root@windriver-machine shtest]# echo $auth
sdfasdfas
[root@windriver-machine shtest]# read -n 1 key
1[root@windriver-machine shtest]#
[root@windriver-machine shtest]# echo $key
1
[root@windriver-machine shtest]# read -dq -p "imput something end with q:" menu
imput something end with q:wobiq[root@windriver-machine shtest]# echo $menu
wobi
[root@windriver-machine shtest]# read -e myfile
hello
[root@windriver-machine shtest]# cat myfile
The log files have all been done
[root@windriver-machine shtest]# read -e myfile
ll
[root@windriver-machine shtest]# read -e myfile testfile

[root@windriver-machine shtest]#

【3】cat 显示文件内容,它显示内容与more和head命令不同,它不会分页显示,而是全

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号