Linux的shell脚本语言是什么
发表于:2024-09-24 作者:千家信息网编辑
千家信息网最后更新 2024年09月24日,这期内容当中小编将会给大家带来有关Linux的shell脚本语言是什么,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。shell 是操作系统中"提供使用者使用界面"的
千家信息网最后更新 2024年09月24日Linux的shell脚本语言是什么
这期内容当中小编将会给大家带来有关Linux的shell脚本语言是什么,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
shell 是操作系统中"提供使用者使用界面"的软件,它包在 linux 内核的外面,为用户和内核之间的交互提供了一个接口,系统中的命令用 shell 去解释,shell 接收系统回应的输出并显示其到屏幕中。
1.shell简介
- 解释性语言--shell脚本、python,运行效率低,基本只适用企业内部
shell--脚本,记录系统命令及命令执行的系统关系,充当解释器
gcc --编译器
vim --编辑器
#!/bin/bash 幻数,指定解释器#!/usr/bin/env bash 自动匹配解释器
描述性语言--C语言、java,执行效率高
1.脚本的调用
脚本(一般以.sh结尾):
[root@desktop5 mnt]# vim westos.sh#!/bin/bash echo hello westos
方法一:无执行权限,用sh调用
[root@desktop5 mnt]# sh westos.sh
方法二:有执行权限,用绝对路径调用
[root@desktop5 mnt]# chmod +x westos.sh [root@desktop5 mnt]# /mnt/westos.sh
2.脚本的检查
+ 表示:执行动作
无+表示:动作输出
方法一:
[root@desktop5 mnt]# sh -x /mnt/westos.sh
方法二:
[root@desktop5 mnt]# vim westos.sh#!/bin/bash -xecho hello westos
实验一:快捷键F4执行填充
方法一:
[root@desktop5 mnt]# vim /etc/vimrc mapms:call WESTOS() 's ##ms:执行命令时,不提示报错function WESTOS() call append(0,"#################################") call append(1,"# Author : Hao #") call append(2,"# Mail : Hao@westos.com #") call append(3,"# Version : 1.0 #") call append(4,"# Create_Time: ".strftime("%Y-%m-%d")." #") ##时间更新call append(5,"# Description: #") call append(6,"#################################")endfunction
方法二:利用.来承接后面的#
mapms:call WESTOS() 'sfunction WESTOS() call append(0,"#################################") call append(1,"# Author : Hao".(" #")) call append(2,"# Mail : Hao@westos.com".(" #")) call append(3,"# Version : 1.0 ".(" #")) call append(4,"# Create_Time: ".strftime("%Y-%m-%d").(" #")) call append(5,"# Description: ".(" #")) call append(6,"#################################")endfunction
测试:
[root@desktop5 mnt]# vim westos.sh ##按'F4'执行填充
实验二:执行新建以.sh结尾的vim文件时,自动填充
注意:旧文件不自动填充
方法一:
[root@desktop5 mnt]# vim /etc/vimrc autocmd BufNewFile *.sh exec ":call WESTOS()" ##新文件,以.sh结尾,执行,调用文件"mapms:call WESTOS() 's ##此行注释,在此"表注释function WESTOS() call append(0,"#################################") call append(1,"# Author : Hao #") call append(2,"# Mail : Hao@westos.com #") call append(3,"# Version : 1.0 #") call append(4,"# Create_Time: ".strftime("%Y-%m-%d")." #") call append(5,"# Description: #") call append(6,"#################################") call append(7,"") call append(8,"#!/bin/bash")endfunction
方法二:
[root@desktop5 mnt]# vim /etc/vimrc autocmd BufNewFile *.sh exec ":call WESTOS()""mapms:call WESTOS() 'sfunction WESTOS() call append(0,"#################################") call append(1,"# Author : Hao".(" #")) call append(2,"# Mail : Hao@westos.com".(" #")) call append(3,"# Version : 1.0 ".(" #")) call append(4,"# Create_Time: ".strftime("%Y-%m-%d").(" #")) call append(5,"# Description: ".(" #")) call append(6,"#################################") call append(7,"") call append(8,"#!/bin/bash")endfunction
测试:
[root@desktop5 mnt]# vim file1.sh ##新建以.sh结尾的文件,自动填充
2.shell脚本练习
练习一:显示当前主机ip地址
[root@desktop5 mnt]# vim ip_show.sh#!/bin/bashifconfig eth0 | awk -F " " '/inet /{print $2}' ##inet所在行,以空格间隔,第二个字符
测试:
[root@desktop5 mnt]# sh ip_show.sh
练习二:显示当前主机中能登陆系统的用户
[root@desktop5 mnt]# vim user_show.sh#!/bin/bashawk -F : '/bash$/{print $1}' /etc/passwd ##以bash结尾,打印出第一个字符
测试:
练习三:执行命令后可清空日至
方法一:
[root@desktop5 mnt]# vim clear_log.sh#!/bin/bash> /var/log/messages
方法二:
[root@desktop5 mnt]# vim clear_log.sh#!/bin/bashecho "" > /var/log/messages
测试:
[root@desktop5 mnt]# chmod +x clear_log.sh [root@desktop5 mnt]# /mnt/clear_log.sh
上述就是小编为大家分享的Linux的shell脚本语言是什么了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。
方法
脚本
系统
语言
命令
文件
测试
解释
解释器
主机
内容
内核
动作
字符
效率
权限
注释
用户
分析
实验
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
怎么找服务贸易的数据库
网址服务器
查看数据库文件命令
美国的软件开发有多强大
网络安全教育(百度文库)
韶关软件开发贵吗
line 服务器地址
在武汉学软件开发
路由器远程服务器没有响应
域控时间服务器
现代网络安全问题的内涵和重要性
数据库所含操作对象
武装突袭3服务器连接不上
一直显示网络安全密钥不正确
网络安全标语学校
三百大作战中的服务器维修要多久
数据库系统数据的存储步骤
软件开发风险识别
网络安全三年级手抄报a4纸视频
网络安全章报告
极速服务器管理工具
如何快速掌握网络技术
服务器root密码是什么格式
腾讯云轻应用服务器安全组
蔡甸订制软件开发
云服务器设备租赁和谁租
access数据库总结报告
身份证号数据库无此号码
网络安全防护哪家好
网络安全主题画 手抄报图片