
shell
mygodhome
走自己的路,带上自己的猫,让别人去说吧……
展开
-
Calculate Elapsed Time shell script(计算消耗时间)
当我们用spool log的方式记录RMAN的输出,计算该输出里所有Elapsed Time的时间和:Here is Calculate Time shell script :=========================================================#!/bin/shlogfile=$1grep elapsed $logfile |awk -F " " '{print $NF}' > /tmp/timeList;...原创 2021-02-02 11:36:34 · 220 阅读 · 0 评论 -
ORACLE: Create block chain table and insert into data
Create Block Chain tablesqlplus / as sysdba <<EOFset echo on;set feedback on;select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;col name form a20;select inst_id,name,open_mode from gv\$pdbs where name='${tpdb}';alter session set cont.原创 2021-02-01 15:11:31 · 159 阅读 · 0 评论 -
在指定文本中向指定变量所在的行后追加关键词 shell 实现
$ cat a.txt1.Anna2.you3.hihi, welcome$ cat d.sh#!/bin/shexport keyword=hihiawk -vn=2 -vm=1 -v bctvar="$keyword" 'BEGIN{FS=OFS=" "}$n=="#linux64"{$m=bctvar}1' label.txt >tmp.logcat tmp.log$ bash d.sh1.wo2.you3.hihi, welcome #linu...原创 2021-01-19 16:21:14 · 477 阅读 · 0 评论 -
BCT query 隐含参数
List the parameter name and its value:col name for a50;col value for a20;select a.KSPPINM name,b.KSPPSTVL value from x$ksppi a,x$ksppcv b where a.INDX=b.INDX and a.KSPPINM like '%_bct%';List the value of the parameter:select KSPPSTVL from x$ks...原创 2020-08-03 14:53:10 · 348 阅读 · 0 评论 -
shell 去除首尾空格
经常碰到的场景,需要去除字符串中的前后的空格。在Shell中不像其他语言有strip()来处理,不过也是可以使用诸如awk等命令来处理。下面是一个简单示例: 1 [root@localhost ~]# echo ' A B C ' | awk '{gsub(/^\s+|\s+$/, "");print}' ^\s+ 匹配行首一...原创 2020-03-18 14:11:17 · 6217 阅读 · 0 评论 -
Example: oracle-18c-preplugin-backups-including-restore-and-recovery-test
https://mandysandhu.com/2018/03/15/oracle-18c-preplugin-backups-including-restore-and-recovery-test/转载 2019-07-15 15:15:31 · 176 阅读 · 0 评论 -
vim 中的替换
查找与替换:s(substitute)命令用来查找和替换字符串。语法如下::{作用范围}s/{目标}/{替换}/{替换标志}例如:%s/foo/bar/g会在全局范围(%)查找foo并替换为bar,所有出现都会被替换(g)。作用范围作用范围分为当前行、全文、选区等等。当前行::s/foo/bar/g全文::%s/foo/bar/g选区,在V...转载 2019-06-19 13:51:59 · 48865 阅读 · 2 评论 -
Shell 数组元素个数${#array[@]} 数组的所有元素${array[*]} 字符串长度${#str}
http://www.cnblogs.com/magicyang/archive/2011/09/01/2162246.htmlShell 数组元素个数${#array[@]} 数组的所有元素${array[*]} 字符串长度${#str}1、获取数组元素的个数: array=(bill chen bai hu); num=${#array[@]} ...转载 2018-04-16 15:53:50 · 20315 阅读 · 2 评论 -
tihuan yuanwen zhiding neirong
#!/bin/shsed -i 's/c_on_i/Change_on_i11/g' `grep c_on_i -rl /tmp`原创 2017-02-26 19:58:11 · 446 阅读 · 0 评论 -
shell 和 python3 :Word Frequency(leetcode192-t11.sh)
AdminWrite a bash script to calculate the frequency of each word in a text file words.txt.For simplicitythe day is sunny the thethe sunny is is原创 2016-11-12 14:04:22 · 712 阅读 · 0 评论 -
若干题
1.从 a.log 文件中提取包含“WARNING”或”FATAL”,同时不包含“IGNOR”的行,然后,提取以“:”分割的第五个字段?grep -E 'WARNING| FATAL' a.log | grep -v 'IGNOR'| awk -F ':' 'print {$5}'2.添加一个新组为class01,然后,添加属于这个组的30个用户,用户名的形式为stdXX,其中,XX从 01到 3原创 2016-11-08 18:22:54 · 582 阅读 · 0 评论 -
Valid Phone Numbers(leetcode193-t5.sh)
5.Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers. You may assume that a valid phone number must appear in原创 2016-11-07 18:57:23 · 260 阅读 · 0 评论 -
鸟同学的几道经典shell题
sed 命令可以很好的进行行匹配,但从某一行中精确匹配某些内容,则使用 grep 命令并辅以 -o 和 -E 选项可达到此目的。其中 -o 表示“only-matching”,即“仅匹配”之意,只输出匹配的部分。光用它不够,配合 -E 选项使用扩展正则表达式则威力巨大。原创 2016-11-09 10:46:49 · 434 阅读 · 2 评论 -
Transpose File(leetcode194-t12.sh)
Transpose FileTotal Accepted: 3876Total Submissions: 18849Difficulty: MediumContributors: AdminGiven a text file file.txt, transpose its content.You may assume that each row has the same number of原创 2016-11-14 16:35:12 · 431 阅读 · 0 评论 -
Tenth Line(leetcode195-t4.sh)
How would you print just the 10th line of a file?For example, assume that file.txt has the following content:Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10Your script s原创 2016-11-06 21:42:54 · 469 阅读 · 0 评论 -
两非空数求和t1.sh
2.写一个shell脚本,进行两个数字的相加,如果没有输入参数就输出错误信息和一行使用说明#!/bin/shecho "Please input the first value:"read atest -z "$a"flag=$?if [ $flag != 0 ] ;then echo "Please input the second value:" read bfi原创 2016-11-04 18:54:41 · 629 阅读 · 0 评论 -
shell删除当前目录及递归目录下文件指定字符串
#!/bin/bash function read_dir(){for file in `ls $1` do if [ -d $1"/"$file ] then read_dir $1"/"$file else sed -i /'Hello'/d $1"/"$file原创 2016-11-29 18:36:01 · 1658 阅读 · 0 评论 -
grep 参数合篇
另外shell 里面的反向选择为[!range], 正则里面是 [^range] http://www.jb51.net/article/31207.htmhttp://www.linuxso.com/command/grep.html功能说明:查找文件里符合条件的字符串。语 法:grep [-abcEFGhHilLnqrsvVwxy][-A][-B][-C][-d]转载 2016-11-17 22:25:03 · 289 阅读 · 0 评论 -
sed的基本语法和选项
看到有时候有些人会sed问各种选项。那今天就列一下:sed [options] [script] [inputfile...]上面的语法中,options代表sed命令的选项,常用的选项如下所列:-n:取消默认输出。-e:允许执行多个脚本-f:从脚本文件中读取命令。-i:直接修改原始文件。-l:指定行的长度-r:在脚本中使用扩展正则表达式-s:默认情况下,se原创 2016-11-18 11:25:46 · 515 阅读 · 0 评论 -
Output reverse number输出反序
打印一个给定的数字的反序,如输入10572,输出27501,如果没有输入数据,应该抛出错误和使用脚本说明。在此之前,告诉我你需要在这里使用的算法。#!/bin/bashif [ $# -ne 1 ];then echo "Error:Bad usage for no input a number.\nUsage for this script is : $0 number,then it w原创 2016-11-07 15:18:25 · 578 阅读 · 0 评论 -
输出size大于10K的文件名字(simple)
脚本test8.sh如下:#!/bin/bashstring=`ls -l | awk '$5>10240 {print $9}'`echo "$string"执行:./test8.sh没有输出!!!!原创 2016-11-07 18:11:03 · 830 阅读 · 0 评论 -
求和
要求:假如现在有个文本foo-t1.txt,格式如下: a 1 b 2 c 3 b 4 a 5 d 6 f 7 g 8 c 9 d 10左边一列是随机的字母,右边一列是随机的数字,然后要求写个脚本输出格式为: a 6 b 6 c 12 d原创 2016-11-08 14:55:13 · 415 阅读 · 0 评论