Shell 概述

shell简介

在这里插入图片描述

echo $SHELL

/bin/bash

创建第一个shell脚本

touch helloworld.sh
vim helloworld.sh

在helloworld.sh 中输入如下内容:
#!/bin/bash
echo “helloworld”
在这里插入图片描述

执行shell文件

  1. bash/sh +文件的相对路径或者绝对路径
bash hellowrold.sh 

hello,world

sh /root/hellowrold.sh 

hello,world

  1. 在脚本的路径前加上“.”或者source
. hellowrold.sh 

hello,world

source hellowrold.sh 

hello,world

  1. 采用输入脚本的绝对路径或相对路径执行脚本(必须具有可执行权限+x)
chmod +x hellowrold.sh 
ll hellowrold.sh 

在这里插入图片描述

# 不能直接写hellowrold.sh ,会被当做命令,无法执行。
./hellowrold.sh 

hello,world

 /root/hellowrold.sh 

hello,world

  • bash/sh+脚本、、直接脚本的绝对路径或相对路径执行脚本的方式:是在当前shell 中打开一个子shell 来执行脚本内容,当脚本内容结束,则子shell
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值