shell
sxf_0123
这个作者很懒,什么都没留下…
展开
-
shell自动备份文件或目录到本地和远程主机
#!/bin/bash#Function:Automatically backup a given list of directories #or files, and can retain the N day backup files.#Can be back to the directory specified by the remote host,# but the need转载 2017-04-28 09:03:52 · 543 阅读 · 0 评论 -
shell:读取文件的每一行内容并输出
shell:读取文件的每一行内容并输出 写法一:----------------------------------------------------------------------------#!/bin/bashwhile read linedo echo $linedone ---------------------------------转载 2017-04-26 19:12:47 · 1027 阅读 · 0 评论 -
[shell] tomcat启动脚本评析 - 1. startup.sh
[shell] tomcat启动脚本赏析 - 1. startup.sh让我们一起来欣赏一下tomcat的启动脚本是怎么写的,重点关注一下其中的shell技巧#!/bin/sh #将用sh shell执行PRG="$0" #当前命令,即startup.shwhile [ -h "$PRG" ] ; do #-h同-L,用于判断文件是否是符号连接;这段代码用于找到连接背后的转载 2017-08-04 17:04:29 · 2831 阅读 · 0 评论 -
[shell] tomcat启动脚本评析 - 1. shutdown.sh
# -----------------------------------------------------------------------------# Stop script for the CATALINA Server# -----------------------------------------------------------------------------转载 2017-08-04 17:08:31 · 329 阅读 · 0 评论 -
shell学习
显示目录下所有文件#!/bin/bashfor file in `ls /etc`;do echo $filedone 设置只读变量,在变量前添加readonly就可以定义只读变量,注意给变量赋值,等号前后不能有空格#!/bin/bashmyUrl="http://www.w3cschool"readonly myUrlmyUrl="htpp://www原创 2017-09-29 16:33:41 · 383 阅读 · 0 评论 -
Linux系统LVM逻辑卷创建过程以及自动化脚本
最近在上海新建机房的时候,给了我2台M2机型服务器,在做初始化的时候发现有一堆磁盘:12345678910111213[root@Centos64:~]# fdisk -l | grep '300.1 GB' | sortDisk /dev/sda: 300.1 GB, 300069052416 bytesDisk /dev/转载 2017-11-28 13:25:48 · 1188 阅读 · 1 评论 -
linux下自动挂载硬盘
echo "\n\n开始创建/dev/xvde\n\n"fdisk /dev/xvde n p1pt8epwqESXUecho "\n\n创建/dev/xvde分区完成\n\n"sleep 1secho "\n\n开始创建逻辑卷组,逻辑卷\n\n"pvcreate /dev/xvde1 #创建物理卷vgcreate VolGroup_d原创 2017-11-28 13:27:18 · 4596 阅读 · 0 评论 -
批量删除es索引(索引格式为索引前缀-YYYY-mm-dd)
cre_index.shcurl -XPUT 0.0.0.0:9200/gather-027-20170228curl -XPUT 0.0.0.0:9200/gather-027-20170227curl -XPUT 0.0.0.0:9200/gather-027-20170226curl -XPUT 0.0.0.0:9200/gather-027-20170225curl -原创 2017-12-19 17:02:24 · 2924 阅读 · 0 评论 -
shell 实现当前目录下多个文件合并为一个文件
当前目录下多个文件合并为一个文件1、将多个文件合并为一个文件没有添加换行符find ./ -name "iptv_authenticate_201801*" | xargs cat > iptv_authenticate.txt2、设置换行符^Jfind ./ -name "iptv_authenticate_201801*" | xargs sed 'a\^J' > iptv_a原创 2018-01-31 15:08:26 · 10802 阅读 · 0 评论 -
统计文件数据总量及某字段为空的数量
方法一:1、统计文件总数量wc -l 006_stb_20180113add.csv2、统计第8个字段为空的数量awk -F ',' '$8==""' 006_stb_20180113add.csv | wc -l3、输出所有字段为空的行awk -F ',' '$8==""' 006_stb_20180113add.csv-F后边为字段分隔符方法二:原创 2018-01-16 16:48:19 · 1439 阅读 · 0 评论 -
从ftp服务器获取文件
1、登录ftp[root@manage wdkjnet]# lftp -u sppz_itmsjdh,Nm_sppz@123 0.0.0.0 -p 21用户名:sppz_itmsjdh密码:Nm_sppz@123 ftp服务器:0.0.0.0端口:212、定位本地目录lcd /tmp3、下载到本地目录get SPPZ_ITMS_JDH_01W_20180114原创 2018-01-16 17:38:11 · 5499 阅读 · 0 评论 -
Linux远程登录服务器
linux 下登录远程服务器linux 下登录远程服务器的方式有两种,一是ssh,二是telnettelnet使用的是明文传输,传输过程账号和密码容易截获。ssh远程登录比较可靠1、telnet测试端口 IP 端口telnet 0.0.0.0 222、ssh 远程登录服务器2.1使用默认端口ssh 0.0.0.02.2使用端口号登录原创 2018-01-25 10:27:13 · 257 阅读 · 0 评论 -
shell命令统计某列去重后的值
需求:根据MAC获取,MAC对应的硬件版本和软件版本。在根据硬件版本统计MAC的数量$ head test_1.txt00:07:67,EC2108,HWV010537P000000:07:63,Z83,ZNV861010P122500:07:67,EC6108V9U_ca_sccdx,HWV218012P000000:07:63,SBox8900hisi3716V3,ZGV865012P0001...原创 2018-03-13 15:00:39 · 3092 阅读 · 0 评论 -
Linux查看History记录加时间戳小技巧
Linux查看History记录加时间戳小技巧Linux查看History记录加时间戳小技巧 熟悉bash的都一定知道使用history可以输出你曾经输入过的历史命令,例如 [root@servyou_web ~]# history | more 6 ./test.sh 7 vim test.sh 8 ./test.sh 但是这里只显示...原创 2018-03-30 20:55:58 · 3390 阅读 · 0 评论 -
linux下tail、grep命令
1、tail -F /home/sxf/yy/python/exer2/test1.log | grep bb #查看test1.log中包含bb的数据2、tail -f 日志文件 # 监控日志文件,再次执行某个程序时,该日志文件能够看到日志信息的输出3、tail -f /home/sxf/yy/python/exer2/test1.log | awk '{ if (mat...原创 2018-03-30 21:01:30 · 2560 阅读 · 0 评论 -
shell脚本基础1
1、shell脚本执行的三种方式 bash 脚本文件名 或 sh 脚本文件名 path/脚本文件名 或 ./脚本文件名 source 脚本文件名 或 . 脚本文件名其中,第一种方法不需要将文件设置为可执行文件,第二种方法需要将文件使用chmod +x 脚本文件名 或者 使用命令 chmod 755 脚本文件名 将文件修改为可执行文件。第三种方法也不需要修改脚本权限。...原创 2018-05-01 10:23:21 · 126 阅读 · 0 评论 -
使用shell脚本采集系统cpu、内存、磁盘、网络等信息
一、cpu信息采集1).采集cpu使用率采集算法:通过/proc/stat文件采集并计算CPU总使用率或者单个核使用率。以cpu0为例,算法如下:1. cat /proc/stat | grep ‘cpu0'得到cpu0的信息2. cpuTotal1=user+nice+system+idle+iowait+irq+softirq3. cpuUsed1=user+nice+system+irq+s...转载 2018-04-29 16:37:16 · 1466 阅读 · 0 评论 -
shell 求和的方法
#!/bin/sh#sum.sh#1total=0for((i=0;ido total=$(($total+$i))doneecho $total#2total2=0while [ $# -gt 0 ] #参数求和do total2=$(($total2+$1)) shiftd原创 2017-04-26 10:41:46 · 5091 阅读 · 0 评论 -
C程序调用shell脚本共有三种方法
C程序调用shell脚本共有三种方法:1、system() #直接放入shell脚本路径在c_call_shell.c文件 1#include 2 #include 3 #include 4 #include 5 6 void c_call_shell(char *shell_path) 7 { 8 char str[]="/u原创 2017-04-25 16:13:45 · 1465 阅读 · 0 评论 -
shell 实现对集群中的网络检测
#!/bin/sh#node_stat.shfor node in `cat /etc/hosts|awk '(NR>=3){print $2}'`do# echo "node="$node ping -c 1 $node &> /dev/null if [ $? = 0 ];then ech原创 2017-04-30 10:35:04 · 544 阅读 · 0 评论 -
linux/shell 文本文件删除/删掉空行
分别用sed awk perl grep 实现:1 sed '/^$/d' input.txt > output.txt #output file: output.txt2 sed -i '/^$/d' input.txt #output file: input.txt3 awk 'NF > 0' input.txt > output.txt #output f转载 2017-04-30 11:02:09 · 724 阅读 · 0 评论 -
linux awk 内置变量使用介绍
linux awk 内置变量使用介绍awk是个优秀文本处理工具,可以说是一门程序设计语言。下面是awk内置变量。 一、内置变量表属性说明$0当前记录(作为单个变量)$1~$n当前记录的第n个字段,字段间由FS分隔FS输入字段分隔符 默认是空格NF当前记录中转载 2017-04-30 11:15:58 · 248 阅读 · 0 评论 -
Linux查看物理CPU个数、核数、逻辑CPU个数
# 总核数 = 物理CPU个数 X 每颗物理CPU的核数 # 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数# 查看物理CPU个数cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l# 查看每个物理CPU中core的个数(即核数)cat /proc/cpuinfo| grep "cpu cores转载 2017-04-30 11:59:27 · 247 阅读 · 0 评论 -
监控集群的状态
#!/bin/sh#node_stat.shrm -rf t1.txtnode_num=`sed '/^$/d' /etc/hosts|wc -l`for node in `cat /etc/hosts|awk '(NR>=3&&NRdo# echo "node="$node ping -c 1 $node &> /dev/null原创 2017-05-01 21:36:06 · 480 阅读 · 0 评论 -
Shell脚本编程35讲视频教程
Shell脚本编程35讲视频教程http://www.360doc.com/content/15/0502/19/3167194_467510602.shtml转载 2017-04-23 19:22:44 · 6893 阅读 · 6 评论 -
云之梦视频
云之梦视频http://www.yzmedu.com/转载 2017-04-23 20:05:32 · 881 阅读 · 0 评论 -
Shell 实现循环出现省略号
#!/bin/shfunction start_pro(){ min=1 max=2 while [ $min -le $max ] do for((i=0;i do printf "." #printf " " #printf "\b" sleep 1 done tab原创 2017-04-24 20:14:08 · 1328 阅读 · 0 评论 -
shell
#include #include #include typedef struct _link //定义结构体统计单词、和该单词个数{ char *data; int num; struct _link *next; }link; void sort(link *phead){ link *p;//i原创 2017-04-24 20:16:44 · 351 阅读 · 0 评论 -
Rsync 使用简单介绍之Shell
Rsync 使用数据备份完成后该操作会自行终止。对于此,最好是在上述命令的基础上再添加一个“-a”选项(对于文件)和“-e”选 项,指定使用远程的shell程序,以保障安全。此时,远端的shell将使用一个加密协议,比如ssh,以便远程的shell可以使用-e ssh格式。这 样,上述Rsync 使用命令就有了ssh加密协议的保护,具体形式如下:rsync -a -e ssh loca转载 2017-04-24 20:43:42 · 693 阅读 · 0 评论 -
PHP 中使用命令行工具 在 Web 应用程序中运行 shell 命令
学习如何更好地集成脚本和命令行工具。本文考察如何使用 shell_exec()、exec()、passthru() 和 system();安全地将信息传递到命令行;以及安全地从命令行获取信息。如果您使用过 PHP,您就会发现它是创建特性丰富的 Web 页面的出色工具。作为一大脚本语言,PHP:容易学习。有许多强大的框架(比如 CakePHP 和 CodeIgniter),让您能够像转载 2017-04-24 20:55:48 · 979 阅读 · 0 评论 -
phpweb后台拿shell简单方法
关于phpweb后台拿shell简单方法。 首先登录后台admin.php 登录后台管理系统后,然后把下面的文件保存为xxx.html,修改action,把 www.xxx.com 改成你的目标网站地址。 代码文件如下: 然后选择你的马儿再上传 上传后如果为iis转载 2017-04-24 20:59:35 · 5942 阅读 · 0 评论 -
rsync实现文件同步
rsync实现文件同步rsync是类unix系统下的数据镜像备份工工具,一般linux系统都自带了 [可以确认一下:shell>rpm -qa|grep rsync]服务端:192.168.1.2 同步目录:/home/source客户端:192.168.1.3 同步目录:/home/receive1、服务端配置shell>vi /etc/rsyncd.conf #转载 2017-04-24 21:12:15 · 380 阅读 · 0 评论 -
mpi中程序在集群中的分发
我们在开发mpi程序时,由于其是分布式程序,我们在单个节点上完成编码后,需要将代码拷贝到整个集群进行测试。集群之间的文件拷贝可以通过scp命令完成。但是scp命令是针对两个节点之间文件互传设计,为了将代码拷贝到所有的机器,我们需要多次调用scp命令。一个好的方法是将拷贝命令写成脚本,让其自动完成。 首次拷贝时,我们可以让scp拷贝整个工作目录到集群中,当项目较小时这种方法没有影转载 2017-04-24 21:27:22 · 1292 阅读 · 0 评论 -
shell
#!/bin/sh# cp /home/sxf/word.txt /home/sxf/4_23/#rm -rf /home/sxf/tt.txtsort /home/sxf/tt.txt > /home/sxf/sort.txt#quit normalif [[ $? -eq 0 ]];then echo "原创 2017-04-24 22:16:55 · 236 阅读 · 0 评论 -
awk调用shell命令与getline和system函数
awk调用shell命令与getline和system函数 如下内容from http://blog.sina.com.cn/s/blog_3ef3b17a0100dzw0.html 有颜色的内容为自己添加的。awk可以用getline或system来调用shell的命令1 getline通过在awk内使用管道,可以把shell命令的输出传送给awk转载 2017-04-25 10:49:57 · 965 阅读 · 0 评论 -
shell 实现读取文件某行的内容
[root@node2 sxf]# cat /etc/hosts #查看文件内容127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain原创 2017-04-25 14:38:45 · 12401 阅读 · 0 评论 -
shell 常用命令
1、查找文件中某个字符串,并显示该字符串所在行号cat airflow.cfg | grep -n 'Log format'2、带行号查看文件内容cat -n airflow.cfg 3、原创 2018-09-13 15:00:58 · 106 阅读 · 0 评论