shell中如何取括号中的字符
来源:互联网 发布:名扬三角洲淘宝店铺 编辑:程序博客网 时间:2024/05/17 22:04
1. 使用grep(结果带括号,不知道有没有办法仅把括号中的内容匹配出来)
1
2
3
4
5
6
7
$a=
'abc[edg]adfirpqu'
$echo $a|grep -o
'\[.*\]'
#中括号的处理需要转义
[edg]
$b=
'abc(edg)adfirpqu'
$echo $b|grep -o
'(.*)'
(edg)
2. 使用cut
1
2
3
4
5
6
7
$a=
'abc[edg]adfirpqu'
$echo $a|cut -d
'['
-f2|cut -d
']'
-f1
edg
$b=
'abc(edg)adfirpqu'
$echo $a|cut -d
'('
-f2|cut -d
')'
-f1
edg
3. 使用字符串截取
1
2
3
4
5
6
7
8
$a=
'abc[edg]adfjaierqpwe'
$b=${a#*[}
$echo $b
edg]adfjaierqpwe
$c=${b%]*}
$echo $c
edg
阅读全文
0 0
- shell中如何取括号中的字符
- shell中的括号(小括号,大括号,中括号)
- shell中的括号(小括号,中括号,大括号)
- shell中的括号(小括号,中括号,大括号)
- shell中的括号(小括号,中括号,大括号)
- shell中的括号(小括号,中括号,大括号)
- shell中的括号(小括号,中括号,大括号)
- Shell 中的中括号用法
- shell中的括号(小括号,中括号,大括号/花括号)
- Shell 中的中括号用法总结
- 取括号中的内容
- shell 小括号中括号大括号
- [shell] 小括号、中括号、大括号
- shell编程中的括号
- SHELL 中的括号
- shell 中的双括号
- shell中的各种括号
- shell中的括号
- 批量删除表
- nginx+tomcat+memcache负载均衡动静分离
- js实现html页面转为pdf下载
- 枚举
- Java基础面试之集合框架
- shell中如何取括号中的字符
- SEO-百度搜索的调整
- Spring Aop的一个简单列子 (确实浅显易懂好文章!)
- angular页面在ios上title标题无法显示问题
- hadoop2.7.3版本FileSystem调用过程(1)
- Java数据结构详解(三)-ArrayList
- BZOJ 1217: [HNOI2003]消防局的设立
- python--leetcode561. Array Partition I
- iOS11: 使用Xcode9后的11条小建议 韩俊强的博客