随笔分类 - shell
摘要:#!/bin/bash #修改成自己的ip、密码、库名以及所要匹配的字符串 db_ip=192.168.1.100 db_port=6379 password=963852741 dbnum=0 str="niubi:*" cursor=0 cnt=1000 new_cursor=0 redis-c
阅读全文
摘要:假设我们定义了一个变量为:file=/dir1/dir2/dir3/my.file.txt 可以用${ }分别替换得到不同的值:${file#*/}:删掉第一个/ 及其左边的字符串:dir1/dir2/dir3/my.file.txt${file##*/}:删掉最后一个/ 及其左边的字符串:my.f
阅读全文
摘要:先指定范围,再对匹配上的内容进行替换 sed -i '5,10 s#hello#world#' test.txt
阅读全文