linux sed 批量替换字符串
#################################################### 获取文件内容处理输出 ############################################################## #解析入库配置,获取表名: echo -e '[table]\ntablename=entry_listquery_fatdt0|flatcookie_fatdt0|path_fatdt0|path_stream_fatdt0|refer_listquery_fatdt0' > ./testfile sed -n 's/^tablename=//p' ./testfile | sed -e 's/|/\n/g' -e 's/\r//g' | sort | uniq > ./test_tablename #(-n)选项和p标志一起使用表示只打印那些发生替换的行 #(-e)选项允许在同一行里执行多条命令,上面是将'|'替换为换行,然后将\r去除 #校验入库配置表名和文件名数量是否一致: tableCount=`wc -l ./test_tablename` fileCount=`ll jobs/EnLog/DFSLoader/conf/loaddb | wc -l ` fileCount=`echo $fileCount-1 | bc`