关键字: 各种编辑语言里预留的已经给本语言使用的名字
定义变量: 不予许变量名以数字开头
[root@localhost ~]# bash /root/.bashrc
产生一个子进程bash去执行脚本 --》在子进程里运行
[root@localhost ~]# source /root/.bashrc
在当前bash进程里执行脚本 --》在父进程里运行
进程: 父进程 子进程
[root@localhost ~]# sg="m"
[root@localhost ~]# mn="s"
[root@localhost ~]# echo $sg $mn
m s
[root@localhost ~]#
[root@localhost ~]# vim output.sh#!/bin/bash ---》申明这个脚本默认使用/bin/bash这个解释器去执行
echo $sg
echo $mn
city='changsha'echo "
$city is a good place"
[root@localhost ~]# source output.sh 在当前bash里执行output.sh
m
s
changsha is a good place
[root@localhost ~]# bash output.sh 启动一个子bash进程去执行output.sh
changsha is a good place
[root@localhost ~]# export sg mn 输出sg和mn变量为全局变量[root@localhost ~]# bash output.sh
m
s
changsha is a good place
[root@localhost ~]#
[root@localhost ~]# ./output.sh
其实也是执行当前目录下的output.sh
-bash: ./output.sh: Permission denied 权限不拒绝
[root@localhost ~]# chmod +x output.sh 授予可执行权限
[root@localhost ~]# ./output.sh 执行当前目录下的output.sh脚本m s
changsha is a good place
[root@localhost ~]# cat output.sh
#!/bin/bash
echo $sg
echo $mncity='changsha'
echo "$city is a good place"
[root@localhost ~]#[root@localhost ~]# chmod -x output.sh 去除可执行权限
-rwxr-xr-x 1 root root
77 Nov 20 15:02 output.sh
user group
文件的信息读取
- 代表普通的文件
- d 代表是文件夹 directory
- l 代表的是链接文件 link
- rwxr-xr-x 代表权限 r read 读 w write 写 x execute 执行user group others
- user--》u
- group -->g
- others -->o
- all -->a
[root@localhost ~]# chmod u+x output.sh
[root@localhost ~]# ll output.sh
-rwxr--r-- 1 root root 77 Nov 20 15:02
output.sh
[root@localhost ~]# chmod a+x output.sh
[root@localhost ~]# chmod g+x output.sh
[root@localhost ~]# chmod o+x output.sh
[root@localhost ~]#
执行: 可以理解为运行这个文件里面的命令
[root@localhost lianxi]# ls
hunan
[root@localhost lianxi]# mkdir guangdong
[root@localhost lianxi]# ls
guangdong hunan
[root@localhost lianxi]# ln -s guangdong
yue 创建链接文件yue指向guangdong
ln 是创建链接文件的命令
-s 创建符号链接(软链接)--》相当于windows里的快捷方式
[root@localhost lianxi]#
lltotal 0
drwxr-xr-x 2 root root 6 Nov 20 15:28
guangdong
drwxr-xr-x 3 root root 22 Nov 13 15:03
hunan
lrwxrwxrwx 1 root root 10 Nov 20 15:28 yue -> guangdong/
[root@localhost lianxi]# ls
guangdong hunan yue
[root@localhost lianxi]# cd yue
[root@localhost yue]# mkdir guangzhou
[root@localhost yue]# ls
guangzhou
[root@localhost yue]# cd ..
[root@localhost lianxi]# ls
guangdong hunan yue
[root@localhost lianxi]# cd
guangdong/
[root@localhost guangdong]# ls
guangzhou
[root@localhost guangdong]#
[root@localhost lianxi]# ln -s hunan xiang
源文件 链接文件
[root@localhost lianxi]# ll
total 0
drwxr-xr-x 3 root root 23 Nov 20 15:28 guangdong
drwxr-xr-x 3 root root 22 Nov 13 15:03 hunan
lrwxrwxrwx 1 root root 5 Nov 20 15:34 xiang -> hunan
lrwxrwxrwx 1 root root 10 Nov 20 15:28 yue -> guangdong/
[root@localhost lianxi]#
|