欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

shell脚本执行方式

程序员文章站 2022-07-09 22:17:40
...
一 echo输出命令
echo [选项] [输出内容]
选项:
-e:支持反斜杠控制的字符转换
 
二 控制字符

shell脚本执行方式
            
    
    博客分类: Linux shell脚本 
 
 
三 输出颜色

shell脚本执行方式
            
    
    博客分类: Linux shell脚本 
 
 
四 Xshell设置字符格式方法
选当前会话,然后按照下图操作

shell脚本执行方式
            
    
    博客分类: Linux shell脚本 
 
 
五 脚本执行
1 赋予执行权限,直接运行
chmod 755 hello.sh
./hello.sh
2、通过Bash调用执行脚本
bash hello.sh
 
六 实战
[root@localhost ~]# echo "bls and cangls"
bls and cangls
[root@localhost ~]# echo -e "bls and\b cangls"
bls an cangls
[root@localhost ~]# echo -e "hello"
hello
[root@localhost ~]# echo -e "hel\blo"
helo
[root@localhost ~]# echo -e "h\te\tl\nl\to\t"
h e l
l o
[root@localhost ~]# echo -e "\x68\t\x65\t\x6c\n\x6c\t\x6f\t"
h e l
l o
[root@localhost ~]# echo "嫁人就要嫁凤姐"
嫁人就要嫁凤姐
[root@localhost ~]# echo -e "\e[1;31m嫁人就要嫁凤姐\e[0m"
嫁人就要嫁凤姐
[root@localhost ~]# echo -e "\e[1;35m嫁人就要嫁凤姐\e[0m"
嫁人就要嫁凤姐
[root@localhost ~]# echo -e "\e[1;32m嫁人就要嫁凤姐\e[0m"
嫁人就要嫁凤姐
[root@localhost ~]# echo -e "\e[1;33m嫁人就要嫁凤姐\e[0m"
[root@localhost ~]# vim hello.shell
[root@localhost ~]# .\hello.shell
[root@localhost ~]# chmod 755 hello.shell
[root@localhost ~]# ./hello.shell
天上掉下个林妹妹
[root@localhost ~]# bash hello.shell
天上掉下个林妹妹
  • shell脚本执行方式
            
    
    博客分类: Linux shell脚本 
  • 大小: 128.5 KB
  • shell脚本执行方式
            
    
    博客分类: Linux shell脚本 
  • 大小: 264.3 KB
  • shell脚本执行方式
            
    
    博客分类: Linux shell脚本 
  • 大小: 42.7 KB
相关标签: shell 脚本