linux运行文件命令有哪些
时间:2023-01-28 17:42
linux运行文件命令有:1、使用source执行文件,命令语法为“source 文件名”。2、利用“.”执行文件,命令语法为“. 文件名”。3、使用bash执行脚本文件,命令语法为“bash 文件名”。4、使用“./file”执行脚本文件,命令语法为“./文件名”;此种方式首先得给脚本添加执行权限“chmod +x 文件名”。 本教程操作环境:linux7.3系统、Dell G3电脑。 创建文件 执行(运行)文件的方式 1、 使用source执行脚本 输出: 使用的为当前bash 2、 使用.执行脚本 使用的为当前bash 3、 使用bash执行脚本 进程id更新了,且未获取到变量test的值,因为启动了子进程的bash执行脚本。 4、 使用./file执行脚本 注意:此种方式首先得给脚本添加执行权限 chmod +x test.txt 进程id更新了,且未获取到变量test的值,因为启动了子进程的bash执行脚本。 推荐学习:Linux视频教程 以上就是linux运行文件命令有哪些的详细内容,更多请关注gxlsystem.com其它相关文章!vi test.txt
# 按i切换insert模式
# 输入文本
#!/bin/bash
echo "Hello world!!!"
echo $$ # 打印当前进程id
echo $test
test=100
source test.txt
Hello world!!!
37790
100
. test.txt
Hello world!!!
37790
100
bash test.txt
Hello world!!!
47733
./test.txt
Hello world!!!
47758