shell 编程基础(1)---初识shellscript

来源:互联网 发布:nginx access日志位置 编辑:程序博客网 时间:2024/05/13 12:09

shellscript 是linux下强大的系统管理工具,可以通过bash命令和管道命令直接在linux系统上进行编程,所写的脚本不需要编译就可以执行,对于系统管理而言十分方便。

#!/bin/bash

//指定所需要使用的bash(不写貌似也能运行)

#program#   this is my first program about shell#   data 2015 5 7  cxzPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATH

//指定环境变量,使程序能在任何目录下运行(写了貌似也没用)

echo -e "helloworld \a \n"exit 0  

运行程序时使用指令sh sh01.sh或者直接修改.sh文件的权限chmod 722 *.sh
上述脚本用来在屏幕上打印helloworld

#program#test the function read#20150507read -p "type in your first name   " firstnameread -p "type in your last name    " lastnameecho -e "****\n*****" ${firstname} ${lastname}

使用read 语句给环境变量赋值,并使用echo打印,在read -p中是无法使用\n来进行换行的。

0 0
原创粉丝点击