Ubuntu Linux--4 脚本程序


4 脚本程序

可执行的文本文件即为脚本程序。
脚本文件第一行要求使用#!符号指定一个脚本解释器,如#!/bin/sh#!/usr/bin/python3


4.1 脚本文件的运行

  1. 通过路径+脚本程序:./hello.sh 运行当前目录下的shell脚本程序hello.sh
  2. 通过脚本解释器+脚本程序路径:/bin/sh ./example/hello.sh
  3. ./hello.py
  4. /bin/python3 ./example/hello.py

4.2 shell脚本

用shell语法写出来的脚本即为shell脚本,Linux自带。

  1. 创建shell脚本文件hello.sh,在文本编辑器中编辑,第一行为#!/bin/sh
#!/bin/sh
echo "hello,world"
  1. 添加hello.sh为可执行 chmod +x hello.sh
  2. 执行hello.sh:./hello.sh 记得加上路径

4.3 python脚本

用python语法写出来的脚本即为python脚本。

  1. 创建python脚本文件python.py,在文本编辑器中编辑,第一行为#!/bin/pyrhon3
#!/bin/python3
print(hello,world) 
  1. 添加hello.py为可执行 chmod +x hello.py
  2. 执行hello.py:./hello.py 记得加上路径
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值