Linux 脚本收集
2017-03-13 14:41
381 查看
括号的使用说明
参考:Double parenthesis with and without dollar$(…) means execute the command in the parens and return its stdout.
$ echo "The current date is $(date)" The current date is Mon Jul 6 14:27:59 PDT 2015
(…) means run the commands listed in the parens in a subshell. Example:
$ a=1; (a=2; echo "inside: a=$a"); echo "outside: a=$a" inside: a=2 outside: a=1
$((…)) means perform arithmetic and return the result of the calculation. Example:
$ a=$((2+3)); echo "a=$a" a=5
((…)) means perform arithmetic, possibly changing the values of shell variables, but don’t return its result. Example:
$ ((a=2+3)); echo "a=$a" a=5
${…} means return the value of the shell variable named in the braces. Example:
$ echo ${SHELL} /bin/bash
{…} means execute the commands in the braces as a group. Example:
$ false || { echo "We failed"; exit 1; } We failed
有用脚本收集
文件读取
读取文件目录的所有文件,按行读取每个文件,判断行文字是否包含特定字符串;如果包含,通过特殊字符来split并输出想要的值。#!/bin/sh for filename in /home/okchem/mysqlbackup/*.sql; do while IFS= read line do # display $line or do somthing with $line if [[ $line == *"/ocf/"* ]]; then SUBSTRING=$(echo $line| cut -d'`' -f 2) # 用'`'来拆分,输出数组第二个 echo $SUBSTRING fi done <"${filename}.sql" done
相关文章推荐
- linux下收集系统硬盘,内存使用情况以定时邮件方式发给root的一个脚本
- linux 信息收集脚本。转自insight-labs
- linux下的shll脚本(收集给自己看)
- Linux自动收集某个进程的脚本
- 嵌入式linux开发中一些有用的shell脚本收集整理
- linux常用脚本收集
- 几段非常有用的脚本(来自微软网站,由downmoon精心收集)
- linuxQQ群收集整理
- Linux下Weblogic 8.1自启动脚本
- 一段生成linux passwd的perl脚本
- 自己收集的,linux常用命令解释
- 在Linux使用脚本实现TC控制少数人的下载带宽,如果是网管,正好用得着。
- 一段生成linux passwd的perl脚本
- linux收集日常应用小技巧
- 转向脚本收集
- Mysql 增量备份脚本(Linux)
- Linux/Unix实现自动ftp的shell脚本
- 脚本中心-->>计算机管理示例脚本(收集整理)
- 收集Linux从酝酿到开发初始版本有关的所有资料和信息(1991-1995);
- Linux的一些基本技巧(不断收集,更新中)