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

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

#!/bin/bash

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

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

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

echo -e "helloworld a 
"
exit 0  

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

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

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

版权声明:本文为博主原创文章,未经博主允许不得转载。

原文地址:https://www.cnblogs.com/ironstark/p/4892644.html