tyron's page 不断探索是一件好事,学无止境!

Shell脚本语言

2022-05-25
David


在写shell脚本的时候发现cd切换目录的时候无法切换,还是在当前目录下,这是什么原因呢?

#!/bin/bash
TOP=`pwd`
cd ${TOP}/../XXXXX/rcar-xos/v3.3.0/
ls -l

可以使用下述命令去执行我们的脚本即可。

# way - 1
$ source xxx.sh

# way - 2
# note: . ./xxx.sh .和.中间有个空格!
$ . ./xxx.sh

参考:

  1. Shell脚本语言(语法)
  2. shell脚本基本语法详解

上一篇 GUI设计工具

Comments

Content