22 shell脚本执行方式
来源:互联网 发布:富二代的生活 知乎 编辑:程序博客网 时间:2024/06/05 00:58
1、echo 命令
1.1、普通输出:echo "you are niubi"
1.2、将特殊符号当字符串处理就用单引号:echo 'you are \n niubi!!!'
1.3、-e可以转移反斜线:echo -e "you are \n牛逼"
1.4、echo输出颜色:echo -e "\e[1;31m abcd \e[0m" //这样就输出abcd为红色的了,‘abcd’为要输出的字符出,’3xm‘代表颜色,其他为固定格式
30m:黑色 31m:红色 32m:绿色 33m:黄色 34m:蓝色 35m:洋红色 36m:青色 37m:白色
2 脚本
2.1 vim xxx.sh
2.2 脚本内容
#!/bin/bash ------------------->这个是告诉Linux 这是一个脚本,不能省略,不是注释
#this is test content------------->脚本描述
#author lvxiujun --------->作者
....... ---------->脚本内容
2.3 赋予权限执行
2.3.1 第一种方法(推荐):chmod 755 xxx.sh
./xxx.sh( 或者绝对路径 /home/lvxiujun/xxx.sh)
2.3.2 第二种方法 (不推荐): bash ./xxx.sh(或者绝对路径 /home/lvxiujun/xxx.sh)
3、windows下编写的脚本在linux下可能换行符有语法不兼容,或者linux到windows也一样,需要执行命令相互转换
3.1 windows到Linux 下脚本换行符转换:dos2unix
3.2 linux到windows下脚本换行符转换:unix2dos
【注】:如果操作系统中没有,就用yum安装
- 22 shell脚本执行方式
- SHELL脚本执行方式
- Shell脚本执行方式
- shell脚本执行方式
- shell脚本执行方式
- shell 脚本的执行方式
- 执行Shell脚本的方式
- hive脚本+shell执行方式
- Shell脚本的执行方式:
- Shell基础-脚本执行方式
- Linux-Shell脚本执行方式
- shell(2)脚本执行方式
- shell基础-脚本执行方式
- Linux Shell脚本执行方式
- shell基础:脚本执行方式
- 执行shell脚本的三种方式
- shell脚本的两种执行方式
- shell脚本执行的几种方式
- 带装修的二手房怎么选?看懂这些才能明白!
- shellScript之if_else语句
- Java中ArrayList的实现原理
- 高德地图签名
- Pyramid Scene Parsing Network论文解读
- 22 shell脚本执行方式
- sublime text 快捷键
- iOS release版本中去掉NSLog输出
- acpi_node_get_property_reference
- linux 环境变量
- Android 如何全局获取Context
- markdown
- 横空出世,席卷互联网--评微软等公司数据结构+算法面试100题
- c#打开资源管理器