运维Shell脚本小试牛刀(一)
运维Shell脚本小试牛刀(一)
运维Shell脚本小试牛刀(二)
一: Shell中循环剖析 for 循环.......
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: countloop.sh
# USAGE: ./countloop.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
for i in 1 2 3 4 5 6 #循环1~6
doecho "Thre for loop is run $i times."
done
echo "==============================================================================================================="for linux in Debian Redhat Suse Fedora Centos7 Ubunto
do
echo "current out system is ${linux}....."
done
echo "================================================================================================================"
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: orcmdssub.sh
# USAGE: ./forcmdssub.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
echo "Printing file list in /etc directory........"
for file in `ls /etc/*`
doecho "current print file is: $file"
done
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: forcmdssub.sh
# USAGE: ./forcmdssub.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
echo "Printing file list in /etc directory........"
for file in `ls /etc/*`
doecho "current print file is: $file"
done
[root@www shelldic]# cat forvarscoutents.sh
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: forvarscoutents.sh
# USAGE: ./forvarscoutents.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================filenames="/etc/my.cnf /etc/vconsole.conf /etc/rsyncd.conf /etc/sestatus.conf /usr/local/rs.conf"
# 上面的文件名以空格分割for file in $filenames
do
[ -f $file ] && echo "The file $file was found.." || echo "***** ERROR: The file $file was missing.....*******"
# 如果是文件,则打印文件存在,如果不存在则打印丢失
done
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: simplenestedfor.sh
# USAGE: ./simplenestedfor.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================
for (( i = 0; i < 30; i++ )) #外循环do
for (( j=0; j<160; j++ )) # 内循环
do
echo -n "* " #
doneecho "" #
done
二 : while循环
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: whichreadfile.sh
# USAGE: ./whichreadfile.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================file=$1 # 将位置参数1的值赋值给变量file
if [ $# -lt 1 ];then # 如果脚本未指定参数,则打印使用方法并退出运行
echo "Usage: $0 FILEPATH"
exitfi
while read -r line # 使用read命令从标准输入读取文件的一行,并赋值给变量line
do
echo $line # 打印读取的行
done < "$file"
[root@www shelldic]# cat whilereadfile.sh
#!/bin/bash -
#==================================================================================================================
#
#
# FILE: whichreadfile.sh
# USAGE: ./whichreadfile.sh
# DESCRIPTION:
# OPTIONS: -------
# REQUIREMENTS: ---------
#
# BUGS: ------
# NOTES: --------
# AUTHOR: ---------YangGe (TOM) ,YangGe.freedom@icloud.com
# ORGANIZATION:
# CREATED: 2023-8-24 09:11:20
# REVISION: --------
#
#
#
#
#
#====================================================================================================================file=$1 # 将位置参数1的值赋值给变量file
if [ $# -lt 1 ];then # 如果脚本未指定参数,则打印使用方法并退出运行
echo "Usage: $0 FILEPATH"
exitfi
while read -r line # 使用read命令从标准输入读取文件的一行,并赋值给变量line
do
echo $line # 打印读取的行
done < "$file"
输出测试:
[root@www shelldic]# ./whilereadfile.sh /etc/sudo.conf
#
# Default /etc/sudo.conf file
#
# Format:
# Plugin plugin_name plugin_path plugin_options ...
# Path askpass /path/to/askpass
# Path noexec /path/to/sudo_noexec.so
# Debug sudo /var/log/sudo_debug all@warn
# Set disable_coredump true
#
# Sudo plugins:
#
# The plugin_path is relative to ${prefix}/libexec unless fully qualified.
# The plugin_name corresponds to a global symbol in the plugin
# that contains the plugin interface structure.
# The plugin_options are optional.
#
# The sudoers plugin is used by default if no Plugin lines are present.
Plugin sudoers_policy sudoers.so
Plugin sudoers_io sudoers.so#
# Sudo askpass:
#
# An askpass helper program may be specified to provide a graphical
# password prompt for "sudo -A" support. Sudo does not ship with its
# own passpass program but can use the OpenSSH askpass.
#
# Use the OpenSSH askpass
#Path askpass /usr/X11R6/bin/ssh-askpass
#
# Use the Gnome OpenSSH askpass
#Path askpass /usr/libexec/openssh/gnome-ssh-askpass#
# Sudo noexec:
#
# Path to a shared library containing dummy versions of the execv(),
# execve() and fexecve() library functions that just return an error.
# This is used to implement the "noexec" functionality on systems that
# support C<LD_PRELOAD> or its equivalent.
# The compiled-in value is usually sufficient and should only be changed
# if you rename or move the sudo_noexec.so file.
#
#Path noexec /usr/libexec/sudo_noexec.so#
# Core dumps:
#
# By default, sudo disables core dumps while it is executing (they
# are re-enabled for the command that is run).
# To aid in debugging sudo problems, you may wish to enable core
# dumps by setting "disable_coredump" to false.
#
# Set to false here so as not to interfere with /proc/sys/fs/suid_dumpable
#
Set disable_coredump false
相关文章:

运维Shell脚本小试牛刀(一)
运维Shell脚本小试牛刀(一) 运维Shell脚本小试牛刀(二) 一: Shell中循环剖析 for 循环....... #!/bin/bash - # # # # FILE: countloop.sh # USAGE: ./countloop.sh # DESCRIPTION: # OPTIONS: ------- # …...

screen命令,可以断开服务器连接,依旧能运行你的程序了
可以参考博客1:https://blog.csdn.net/nima_zhang_b/article/details/82797928 可以参考博客2:https://blog.csdn.net/herocheney/article/details/130984403 Linux中的screen是一个命令行工具,可以让用户在同一个终端会话中创建多个虚拟终端。它非常有…...

【ArcGIS Pro二次开发】(63):批量更改字段别名
在我工作中遇到的大多数图斑,字段名称一般是英文,字段别名是中文,使用起来是比较方便的。 但有时候也会遇到一些不一样的情况,不知是经过了怎样的处理,图斑的字段别名被修改成了和字段名称一样的英文,这样…...

redis全套参数配置及降级解决方案
文章目录 redis高可用核心参数配置1.Lettuce2.Jedis3.Redisson4.其他客户端 redis降级场景简介一、业务背景二、设计方案三、实现方案四、总结 redis高可用核心参数配置 1.Lettuce 提示:该客户端无主动探活机制,只能依赖于 OS KeepaAlive 机制…...

AMD即将上市大量中端显卡,为新显卡支付过高价格的日子可能结束
AMD在本周末(8月25日)的德国Gamescom活动中展示了两款新显卡和一些新的升级技术,这些新GPU的定价将与英伟达的GeForce RTX 4000卡竞争。 这是一件大事,因为新的Radeon RX 7700 XT和7800 XT卡占据了AMD Radeon RX 7000系列产品线…...

go学习一之go的初体验
go语言学习笔记 一、golang初体验: 1.简单体验案例: package main{ //把这个test.go归属到main import "fmt" //引入一个包 func main(){//输出hellofmt.Println("hello world")} }2.从案例学到的知识点: (1) go文件的后缀是.…...

智能制造产业链数字化转型、数字化互联工厂建设方案PPT
本资料来源公开网络,仅供个人学习,请勿商用,如有侵权请联系删除,更多浏览公众号:智慧方案文库 篇幅有限,无法完全展示,喜欢资料可转发评论,私信了解更多信息。...

【安卓】拿注册码的两种方式
【安卓】拿注册码的两种方式 文章仅用于学习交流,请勿利用文章中的技术对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。首发吾爱:https://www.52pojie.cn/thread-1826802-1-1.html言归…...

【C++】—— 异常处理
前言: 本期,我将给大家讲解的是有关 异常处理 的相关知识! 目录 (一)C语言传统的处理错误的方式 (二)C异常概念 (三)异常的使用 1、异常的抛出和捕获 1️⃣ 异常的…...

cookie和session是什么,区别是什么?
cookie HTTP 协议中的 Cookie 包括 Web Cookie 和浏览器 Cookie,它是服务器发送到 Web 浏览器的⼀ ⼩块数据。服务器发送到浏览器的 Cookie,浏览器会进⾏存储,并与下⼀个请求⼀起发送到服务器。通 常,它⽤于判断两个请求是否来⾃…...

linux的mmc子系统与块设备关联
1.前言 本文主要block组件的主要流程,在介绍的过程中,将详细说明和block相关的流程,涉及到其它组件的详细流程再在相关文章中说明。 2.主要数据结构和API 2.1 struct mmc_card Elemete Namestruct mmc_cardPathinclude/linux/mmc/card.hRe…...

【Spring MVC】
目录 🍮1 什么是 MVC ? 🎁2 Spring MVC 的连接 🍘2.1 RequestMapping 实现 POST 和 GET 请求 🥣2.2 GetMapping 只支持 GET 请求 🫖2.3 PostMapping 只支持 POST 请求 🍬3 Spring MVC 获取参数的…...

【ES】笔记-生成器函数与调用
function* function* 这种声明方式 (function关键字后跟一个星号)会定义一个生成器函数 (generator function),它返回一个 Generator 对象。 function * gen(){console.log("heloo generator")}如何调用呢?先看下里面的内容 返回…...

将Spring Boot与Redis集成
一、引言 1、SpringBoot: Spring Boot是一个用于创建独立且可执行的Spring应用程序的框架。它简化了基于Spring框架的应用程序的开发过程,并提供了一种快速和简便的方式来构建Java应用程序。 Spring Boot提供了自动配置机制,通过引入适当的…...

vue echarts
安装 npm i -D echarts使用 <script setup lang"ts"> import * as echarts from echarts import { onMounted } from vueonMounted(() > {interface DataItem {value: [string, number]}let myChart echarts.init(document.getElementById(main))let dat…...

idea上利用JDBC连接MySQL数据库(8.1.0版)
1.了解jdbc概念 JDBC(Java DataBase Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种 关系数据库提供统一访问,它由一组用Java语言编写的类和接口组成。JDBC提供了一种基准,据此可以构建 更高级的工具和接口&#…...

【100天精通python】Day47:python网络编程_Web编程基础
目录 1 网络编程与web编程 1.1 网络编程 1.2 web编程 2 Web开发概述 3 Web开发基础 3.1 HTTP协议 3.2 Web服务器 3.3 前端基础 3.4 静态服务器 3.5 前后端交互的基本原理 4 WSGI接口 4.1 CGI 简介 4.2 WSGI 简介 4.3 定义 WSGI 接口 4.4 运行 WSGI 服务 4.5…...

DockerCompose介绍与使用
DockerCompose介绍与使用 1、DockerCompose介绍 DockerCompose用于定义和运行多容器 Docker 应用程序的工具。 通过 Compose可以使用 YAML 文件来配置应用程序需要的所有服务。一个使用Docker容器的应用,通常由多个容器组成,使用Docker Compose不再需要…...

Windows Qt 5.12.10下载与安装
Qt 入门实战教程(目录) C自学精简实践教程 目录(必读) 1 Qt5.12.10下载 qt-opensource-windows-x86-5.12.10.exe 官方离线安装包 Download Source Package Offline Installers | Qt 下载巨慢(也可能很快) 只能下载到最新的&…...

RustDesk最新版本编译与打包
本文环境 主要参考: https://www.yuque.com/shikangsi/efy0cp/wei3g1?https://blog.csdn.net/hualuohuakai2014/article/details/121605631 问题 flutter 生成 bridge 文件。 先安装工具,再生成ffi文件。 PS C:\Users\Administrator> cargo ins…...

Gin 框架入门实战系列(一)
GIN介绍 Gin是一个golang的微框架,封装比较优雅,API友好,源码注释比较明确,具有快速灵活,容错方便等特点 对于golang而言,web框架的依赖要远比Python,Java之类的要小。自身的net/http足够简单,性能也非常不错 借助框架开发,不仅可以省去很多常用的封装带来的时间,…...

【测试】pywinauto的简单使用(安装、常用对象、元素控件、鼠标操作、键盘操作)
1.说明 pywinauto是一个用于自动化Python 模块,适合Windows系统的软件(GUI),可以通过Pywinauto遍历窗口(对话框)和窗口里的控件,也可以控制鼠标和键盘输入,所以它能做的事情比之前介…...

Java基础十八(正则表达式 + 日期时间)
1. 正则表达式 1.1 普通字符 字符描述示例[abc]匹配 […] 中所有字符[hlo] 匹配字符串 "hello world" 中所有的 h l o 字母[^ABC]匹配除了 […] 中所有字符[hlo] 匹配字符串 "hello world" 中除了 h l o 的所有字母[^a-z]匹配除了 […] 中所有字符[hlo] 匹…...

Linux C 多进程编程(面试考点)
嵌入式开发为什么要移植操作系统? 1.减小软硬件的耦合度,提高软件的移植性 2. 操作系统提供很多库和工具(QT Open CV),提高开发效率 3.操作系统提供多任务机制,______________________? (提高C…...

c++一级
与7无关的数 #include<iostream> #include<iomanip> using namespace std; int main() { int n,a,sum0,c0; cin>>n; for(int i1;i<n;i){ if(i%7!0){ ai; c0; …...

Code Lab - 34
GAT里面有一些地方看的不是太懂(GAT里Multi Attention的具体做法),暂时找了参考代码,留一个疑问 1. 一个通用的GNN Stack import torch_geometric import torch import torch_scatter import torch.nn as nn import torch.nn.fun…...

后端返回文件流,前端怎么导出、下载(8种方法可实现)
在前端导出和下载后端返回的文件流时,可以使用以下几种方法: 使用window.open()方法: 在前端使用window.open()方法打开一个新的窗口或标签页,并将后端返回的文件流作为URL传递给该方法。浏览器会自动下载该文件。例如:…...

什么是 ThreadLocal?
ThreadLocal 是 Java 中的一个类,用于在多线程环境下,为每个线程提供独立的变量副本。每个线程可以通过 ThreadLocal 存储和获取数据,而不会影响其他线程的数据。这在某些情况下非常有用,特别是当多个线程需要访问共享数据,但又希望保持数据的隔离性时。 ThreadLocal 主要…...

CANOCO5.0实现冗余分析(RDA)最详细步骤
在地理及生态领域会常使用RDA分析,RDA的实现路径也有很多,今天介绍一下CANOCO软件的实现方法。 1.软件安装 时间调整到2010年 2.数据处理 得有不同的物种或者样点数值,再加上环境因子数据。 3.软件运行 4.结果解读 结果解读主要把握这几点…...

【tkinter 专栏】掷骰子游戏
文章目录 前言本章内容导图1. 需求分析2. 系统功能结构3. 设计流程4. 系统开发环境5. 系统预览6. 窗口布局7. 功能实现用户和电脑选择骰子的点数大小摇骰子过程实现判断游戏结果单击开始按钮进行游戏源代码汇总前言 本专栏将参考《Python GUI 设计 tkinter 从入门到实践》书籍…...