shell 一些题目
在a.log中精确查找含有msyql单词的行
a.log文件内容如下:
mysql
mysql
mysql
mysql a
a mysql
_mysql
a mysql b
_mysql a
a _mysql
a _mysql b
a_mysql
a_mysql b
a_mysql_
a_msyql_b
ab _mysql
ab c _mysql
#mysql
#mysql a
#mysql a
a #mysql
a #mysql b
a#mysql
a#mysql b
a#mysql#
a#msyql#b
ab #mysql
ab c #mysql
$mysql
$mysql a
a $mysql
a $mysql b
a$mysql
a$mysql b
a$mysql$
a$msyql$b
ab $mysql
ab c $mysql
$_mysql
$_mysql a
a $_mysql
a $_mysql b
a$_mysql
a$_mysql b
a$_mysql$_
a$_msyql$_b
ab $_mysql
ab c $_mysql
a mysql b _mysql
a mysql b
ab c mysql
结果如下:
mysql
mysql
mysql
mysql a
a mysql
a mysql b
a mysql b _mysql
a mysql b
ab c mysql
请问通用型的linux命令是什么?(不能用shell脚本)
注:如果只是针对上面的那不是通用型问题,可以添加多一些特殊字符进行测试
awk '{for(i=1;i<=NF;i++) if($i=="mysql")print $0}' a.log
问一个简单的问题:
清空/disk1/logs下所有.log日志的内容,linux命令怎写?(不能用shell脚本)
注:
1.是清空内容不是删除文件
2./disk1/logs目录下有.log文件和二级目录下面也有.log文件
cat /dev/null > test.log
find /disk1/logs -name '*.log' -print|awk '{print "echo > "$0}'|bash
find /disk1/logs -name '*.log' -exec cp /dev/null {} \;
find /disk1/logs -name '*.log' | xargs -I {} cp /dev/null {}
shell 一些题目的更多相关文章
- shell面试题目总结
1.如何理解shell脚本中第一行#!/bin/sh #!为特殊的表示符,其后是解释此脚本的shell的路径.此脚本使用/bin/sh进行解释执行. 2.如何向脚本传递参数. 脚本名字 参数1 参数2 ...
- 二分算法题目训练(一)——Shell Pyramid详解
HDU2446——Shell Pyramid 详解 Shell Pyramid 题目描述(Google 翻译的) 在17世纪,由于雷鸣般的喧嚣,浓烟和炽热的火焰,海上的战斗与现代战争一样.但那时,大炮 ...
- shell脚本练习题
下面列出了几个linux学习中的shell脚本题目 1.九九乘法表 #!/bin/bash echo "九九乘法表" # 注意((之间不能有空格.加减乘除的格式.还有转义字符\*. ...
- 【HDU5730】 Shell Necklace
HDU5730 Shell Necklace 题目大意 已知连续i(1<=i<=n)个贝壳组合成一段项链的方案数a[i],求组合成包含n个贝壳的项链的总方案数. Solution cdq分 ...
- 常用shell脚本
[脚本1]打印形状打印等腰三角形.直角三角形.倒直角三角形.菱形 #!/bin/bash # 等腰三角形 read -p "Please input the length: " n ...
- 【转】干货分享-100个shell脚本
本文用于记录学习和日常中使用过的shell脚本 [脚本1]打印形状 打印等腰三角形.直角三角形.倒直角三角形.菱形 #!/bin/bash # 等腰三角形 read -p "Please i ...
- 大公司的PHP面试题
1. 禁用COOKIE 后 SEESION 还能用吗? 2. 抓取远程图片到本地,你会用什么函数? 4. 你觉得在pV10W的时候, 同等配置下,LUNIX 比WIN快多少? 5. 简述pOST 和G ...
- XCTF攻防世界Web之WriteUp
XCTF攻防世界Web之WriteUp 0x00 准备 [内容] 在xctf官网注册账号,即可食用. [目录] 目录 0x01 view-source2 0x02 get post3 0x03 rob ...
- 从 posix_spawn() 函数窥探漏洞逃逸
posix_spawn() 函数是用来在Linux上创建子进程的,头文件是 #include <spawn.h> ,语法如下: #include <spawn.h> int p ...
随机推荐
- python编程学习day03
1.文件操作 (1)打开文件 f = open ("文件名称",mode='' ",encoding="utf-8") mode=操作方式 encod ...
- phpstrom 注释效果
/** * .,:,,, .::,,,::. * .::::,,;;, .,;;:,,....:i: * :i,.::::,;i:. ....,,:::::::::,.... .;i:,. ..... ...
- 基于Netty的RPC架构学习笔记(八):protocol buff学习使用
文章目录 简介 准备 protobuf配置文件 生成java代码 举个
- 3. Image Structure and Generation
名词 Extensible Linking Format(ELF) 3.1 The structure of an ARM ELF image ARM ELF映像包含sections, regions ...
- POJ-1836-Alignment-双向LIS(最长上升子序列)(LIS+LSD)+dp
In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are al ...
- jq 出现 $.cookie is not a function
出现这种问题有3中可能 1是没有导入cookie相关的库文件 2是cookie的库文件和jquery库文件的先后顺序问题, 必须先导入jquery库文件后到其他库文件 3一个页面由于二次或多次引入了j ...
- mac os Catalina beta andriod studio crash
点击菜单 Help - Edit Custom VM Options 添加下面一行-Dsun.font.layoutengine=icu 然后我自己重启了好几下,然后 在重新创建一个新的工程,就好了 ...
- ionic js 滑动框ion-slide-box 滑动框是一个包含多页容器的组件,每页滑动或拖动切换
ionic 滑动框 ion-slide-box 滑动框是一个包含多页容器的组件,每页滑动或拖动切换: 效果图如下: 用法 <ion-slide-box on-slide-changed=&quo ...
- Aop 简单实例
一 , 定义aop @Aspect @Component public class MyAspect { //* com 这里有个 空格 ! @Pointcut("execution(* c ...
- pdfkit
官方文档 0.准备 需要引入两个包,首先要npm install pdfkit安装pdfkit包 const PDF = require('pdfkit'); const fs = require(' ...