代码开发环境:Eclipse 1.打印字符串: print "Hello world!" myString = "Hello world!" print myString 运行结果: Hello world! Hello world! 2.格式化字符串 print "%s is in the left of railway station %d" % ("huizhi", 2) 运行结果: huizhi is in the l…
1命令行参数 1.1读取参数 bash shell会将一些称为位置参数(positional parameter)的特殊变量分配给输入到命令行中的所有参数.这也包括shell所执行的脚本名称.位置参数变量是标准的数字:$0是程序名,$1是第一个参数,$2是第二个参数,依次类推,直到第九个参数$9. 例子:计算阶乘 $ vim test1.sh #!/bin/bash # using one command line parameter factorial=1 for (( number = 1;…
一.获取用户输入1.基本读取read命令接收标准输入的输入,或其它文件描述符的输入.得到输入后,read命令将数据输入放入一个标准变量中.[root@rac2 ~]# cat t8.sh #!/bin/bash#testing the read commandecho -n "enter your name:" ---:-n用于允许用户在字符串后面立即输入数据,而不是在下一行输入.read nameecho "hello $name ,welcome to my progra…