Shell

SHELL——环境变量

1、系统变量 SHELL环境变量分类: 作用域分类为全局变量和局部变量、 系统变量和用户自定义变量。 打印系统全局变量命令:env、printenv 打印系统局部变量命令:set 在编辑器中查看系统全局变量命令:env | less 在编辑器中查看系统局部变量命令:set | less (全局变量可 ......
变量 环境 SHELL

【代码片段】makefile 中通过 shell 函数执行 sed

作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢! cnblogs博客 zhihu Github 公众号:一本正经的瞎扯 先上代码:(在 macos 上调试通过) # define a shell function to set debug mode to release mod ......
函数 片段 makefile 代码 shell

Shell Issues

Shell Issues Debris 双引号包裹下引用变量,其中的换行符号(不是转义)会被解析,否则会被直接忽视(不会被替换为 \n ),例如: $pre=" I Love You " echo $pre # 输出一行内容 echo "$pre" # 输出多行内容 引用变量时,若其中存储的是字符串 ......
Issues Shell

Shell Scripts

Shell Scripts Shell 编程笔记 基本语法模块 指定脚本解析器 #!/bin/bash #!/bin/sh bash 是最常用的解析器,sh 等其他 shell 解析器与 bash 有语法上的区别 变量 变量名:字母、数字、下划线,数字不可开头 变量赋值: user="festu" ......
Scripts Shell

[Linux] shell文本处理记录 - 查找、增删特定行及附近行

转:https://blog.csdn.net/wy_hhxx/article/details/127416595 查找username所在行并删除此行,输出到新文件sed '/username/,+d' 04filename.log > 04filename_new.log 目录 1.grep查找 ......
文本 Linux shell

shell遍历比较文件夹下文件md5值

#!/bin/bash CURRENT_DIR=$(cd $(dirname $0); pwd) SOURCE_DIR="$CURRENT_DIR/python_data" TARGET_DIR="$CURRENT_DIR/out_bin" cd $SOURCE_DIR > python.md5 f ......
文件 文件夹 shell md5 md

How to add a string that contains whitespace to array in shell script All In One

How to add a string that contains whitespace to array in shell script All In One ......
whitespace contains string script array

linux-Shell将命令行终端输出结果写入保存到文件中

(一)将输出与错误写到同一个文件(1)方法1 #!bin/bashjava -jar hbase-example.jar 2>&1 | tee hbase_log.txt 说明:0,1,2:在linux分别表示标准输入、标准输出和标准错误信息输出。tee默认为写入覆盖,-a参数表示追加内容。 #!b ......
linux-Shell 终端 命令 结果 文件

shell脚本批量自动分发文件

1、安装expect yum -y install expect 2、创建iplist.txt文件(要分发的IP地址) vim iplist.txt 192.168.100.22 192.168.100.23 3、创建pwd.txt(里面包含密码) vim pwd.txt 123456 123123 ......
脚本 文件 shell

Linux shell script if condition control flow methods All In One

Linux shell script if condition control flow methods All In One if...then...fi / if...then...else..fi / if...then...elif...then...fi ......
condition control methods script Linux

linux下的shell

1.查看当前用户默认的shell: cat /etc/passwd 最后面几行,找到用户名 2.查看当前的终端是什么shell echo $SHELL 或者 echo $0 3.查看系统可以使用那些shell cat /etc/shells ......
linux shell

shell脚本中的EOF是什么

概述 在Shell脚本中,EOF(End of File)是一个特殊标记,用于指示一段文本的开始和结束位置。但它并不是Shell脚本中的关键字或保留字。您可以自由选择EOF之前的标记,只需确保开始和结束标记匹配即可。基本上<<EOF告诉 shell 您将输入多行字符串,直到“标记” EOF。您可以根 ......
脚本 shell EOF

从文件路径中提取文件名的shell操作

Sundray-SW /extdir #sfp=/extdir/debug_bin/ops-devsdSundray-SW /extdir #echo ${sfp##*/}ops-devsdSundray-SW /extdir #basename ${sfp}ops-devsdSundray-SW ......
文件 文件名 路径 shell

bash shell快速备忘单

linux bash shell 脚本的快速参考备忘单(全) 原创 诺苏编程 Qt历险记 2023-08-12 14:07 发表于广东 收录于合集 #linux10个 #echo1个 #bash1个 入门 hello.sh #!/bin/bashVAR="world"echo "Hello $VAR ......
shell bash

shell-进程管理脚本

功能函数列表: 1、function get_all_group 返回进程组列表字符串 2、function get_all_process 返回进程名称列表字符串 3、function get_process_info 返回进程详细信息列表字符串,详细信息包括:运行状态、 PID、CPU、MEM、 ......
脚本 进程 shell

shell-sed命令

sed sed主要是用来将数据进行选取、替换、删除、新增的命令 sed [选项] [动作] 文件名 选项: -n:一般sed命令会把所有数据都输出到屏幕,如果加入此选择则只会把经过sed命令处理的行输出到屏幕 -e:允许对输入数据应用多条sed命令编辑 -i:用sed的修改结果直接修改读取数据的文件 ......
shell-sed 命令 shell sed

【问题解决】shell脚本执行错误 $‘\r‘:command not found

问题原因:在 Windows 中,换行符是由回车符(\r)和换行符(\n)组成的,而在 Unix/Linux 等系统中,只使用换行符(\n)作为换行标志。 当你在 Unix/Linux 系统上运行一个包含 Windows 格式换行符的脚本时,Shell 会尝试解释其中的回车符,导致错误提示 $‘\r ......
脚本 错误 command 问题 shell

shell-awk-命令

AWK 是一种处理文本文件的语言,是一个强大的文本分析工具。 FS内置变量 awk -F 字段分隔符(默认是任何空格) 1、截取文档中的某个段 head -n2 /etc/passwd |awk -F ':' '{print $1}' 2、匹配字符和字符串 awk '/oo/' test.txt o ......
shell-awk 命令 shell awk

shell-字符串截取命令

cut cut 命令从文件的每一行剪切字节、字符和字段并将这些字节、字符和字段写至标准输出。 printf 格式化输出命令 输出文件内容 awk 命令 ......
字符串 字符 命令 shell

shell整数计算器

#! /bin/bash checkInt() { arr=$1 for i in "${arr[@]}" ; do temp=`echo $i | sed 's/[0-9]//g' | sed 's/[ ]*//g'` if [ -n "$temp" ]; then echo "$i must b ......
整数 计算器 shell

Linux Shell常用命令总结

1. find find pathname -options [-print -exec -ok] 让我们来看看该命令的参数: pathname find命令所查找的目录路径。例如用.来表示当前目录,用/来表示系统根目录。 -print find命令将匹配的文件输出到标准输出。 -exec find ......
命令 常用 Linux Shell

How to use a shell script to check whether a command had been installed in the Linux server All In One

How to use a shell script to check whether a command had been installed in the Linux server All In One shell script error [: :需要整数表达式 / [: -eq:需要一元表达... ......
installed command whether script server

Shell 腳本字符串處理

删除子串 一下方法都可以用来删除字符串中的指定子串 语法 作用 说明 ${str#rule} 从左开始匹配 最小匹配 ${str##rule} 从做开始匹配 最大匹配 ${str%rule} 从右开始匹配 最小匹配 ${str%%rule} 从右开始匹配 最大匹配 str 表示字符串变量 举例: 假 ......
字符串 字符 Shell

HBASE shell学习

一、基本命令打开 Hbase Shell:# hbase shell1.1 获取帮助# 获取帮助help# 获取命令的详细信息help 'status'1.2 查看服务器状态status1.3 查看版本信息version 关于表的操作2.1 查看所有表list2.2 创建表命令格式: create ......
HBASE shell

Shell中如何分割字符串

使用字符替换来分割字符串 tr 或者 类似实现字符串替换的工具,如 sed。 echo "go:python:rust:js" | tr ":" "\n" # 使用 tr 将分隔符 : 替换成换行符 \n 使用 tr 将分隔符 : 替换成换行符 \n。 使用 cut 分割字符串 echo "go:p ......
字符串 字符 Shell

shell批量执行命令与文件传输脚本

shell批量执行命令与文件传输脚本 实现原理: 需求: 对未进行主机信任操作的服务器进行批量操作 实现: 由于ssh只能在交互模式中输入服务器密码进行登录登操作,不便于进行大批量服务器进行巡检或日志采集。sshpass恰好又解决了这个问题,使用ssh -p passwd可以实现命令行输入密码操作, ......
脚本 命令 文件 shell

shell编程语言

一.什么是编程语言 1.编译型语言 程序在执行之前需要一个专门的编译过程,把程序编译成为机器语言文件,运行时不需要重新翻译,直接使用编译的结果就行了。 程序执行效率高,依赖编译器,跨平台性差些。如golang、C、C++。 2.解释型语言 程序不需要编译,程序在运行时由解释器翻译成机器语言,每执行一 ......
编程语言 语言 shell

shell数组

shell数组 普通数组:只能使用整数作为数组索引(元素的下标) 关联数组:可以使用字符串作为数组索引(元素的下标) 普通数组定义:用括号来表示数组,数组元素(变量)用“空格”符号分割开。定义数组的一般形式为: 一次赋一个值: 变量名=变量值 array[0]=v1 array[1]=v2 arra ......
数组 shell

shell函数

shell函数 shell中允许将一组命令集合或语句形成一段可用代码,这些代码块称为shell函数。给这段代码起个名字称为函数名,后续可以直接调用该段代码的功能。 1.函数的定义 函数名() { 函数体(一堆命令的集合,来实现某个功能) } function 函数名() { 函数体(一堆命令的集合, ......
函数 shell

How to print a string with a variable by using the echo command in the shell script All In One

How to print a string with a variable by using the echo command in the shell script All In One Node.js & nvm ......
the variable command string script