最新消息:20210917 已从crifan.com换到crifan.org

【未解决】shell中用正则提取字符串

字符串 crifan 753浏览 0评论
shell 按照指定内容分割文件 -CSDN论坛
[redhat@localhost shell]$ cat drop_table.txt 
drop table aaa
create table .....
;
drop table bbb
create table .....
;
drop table ccc
create table .....
;
想实现的结果是输出三个文件:
aaa.txt
bbb.txt
ccc.txt
其中文件内容就是:如
#cat aaa.txt
drop table aaa
create table .....
;
同理很多了建表脚本我都要根据表名拆分开。

去想办法,用shell实现。
刚已大概看了看,如果shell不方便,则其实可以换用python脚本去处理的。

shell 正则
Linux awk 命令 | 菜鸟教程
linux awk命令详解 – ggjucheng – 博客园
Shell正则表达式 列表
shell之正则表达式_点滴记录-CSDN博客_shell正则
常见的支持正则表达式的UNIX工具:
grep命令族:用于匹配文本行
sed流编辑器:用于改变输入流
awk:用于处理字符串的语言
more或者less等:文件查看程序
ed,vi或者vim等:文本编辑器
Shell中使用grep、sed正则提取、替换字符串_不若乘风来-CSDN博客_grep正则提取字符串
grep,sed,awk
shell grep regex
Regular expressions in grep ( regex ) with examples – nixCraft
Using Grep + Regex (Regular Expressions) to Search Text in Linux | DigitalOcean
Regular Expressions in grep
grep regular expression syntax (Finding Files)
Grep Regex – How to use Regular Expressions in GREP Easily!


转载请注明:在路上 » 【未解决】shell中用正则提取字符串

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.210 seconds, using 23.36MB memory