Shell脚本
Shell
- Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁(命令解释器)。
- Shell既是一种命令语言,又是一种程序设计语言。
- Shell是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核的服务。
Shell 脚本
Shell 脚本(shell script),是一种为 shell 编写的脚本程序。
我们所说的 shell 通常都是指 shell 脚本,但要知道,shell 和 shell script 是两个不同的概念,
由于习惯的原因,简洁起见,本文出现的 “shell编程” 都是指 shell 脚本编程,不是指开发 shell 自身。
编辑shell脚本:
例1:
创建.sh脚本
[[email protected] Desktop]$ vim test.sh
#!/bin/bash
echo “Hello World !”
[./]执行二进制脚本
[[email protected] Desktop]$ chmod u+x test.sh
[[email protected] Desktop]$ ./test.sh
hello World!
(不修改权限,无法通过**./文件名执行,可通过bash ./**文件名执行)
(修改权限后)
例2:
[[email protected] kk]$ cat test.sh
#!/bin/bash
while true
do
echo "hello word "
sleep 1(睡眠一秒)
done
远程复制编写 copy1.sh 脚本远程复制
编写 copy2.sh for循环实现远程复制
通过shell脚本删除每台机器的文件(相同路径下存在相同的文件)