如何在shell脚本中提取两个符号之间的单词

时间:2013-06-25 11:44:17

标签: search grep find character extract

我有一行

MOD record for (Batch Upload Base Interest Slab Version: Online Services) Appl: GU

我需要打印Batch Upload Base Interest Slab Version。

Starting string (
End string :

我如何实现这一目标。请帮忙

2 个答案:

答案 0 :(得分:1)

awk可以成功

awk -F"[(:]" '{print $2}'
  • -F"[(:]"将分隔符设置为:((快乐的脸!)。

测试

$ echo "MOD record for (Batch Upload Base Interest Slab Version: Online Services) Appl: GU" | awk -F"[:(]" '{print $2}'
Batch Upload Base Interest Slab Version

答案 1 :(得分:0)

试试这个......

$ input=(Batch Upload Base Interest Slab Version: Online Services) Appl: 
$ startString=${x#*(}
$ outputstring=${y%:*}
$ echo $outputstring