像老板一样使用bash - 协同作用

时间:2015-08-05 04:46:34

标签: bash

我有一个需要更改的数据集,我无法证明我需要使用Perl。我正在尝试使用Bash删除“完全权限”。但是,我不仅要删除括号中的内容,还要删除括号本身。我该怎么做,因为当我使用sed时 - 它摆脱了一切!

7X7AMFull rights (Secondary)99999Full rights (Unknown)AAAMFull rights
(Unknown)AAAMAHKFull rights (Unknown)AAAMNLFull rights (Unknown)
AAMAHFull rights (Unknown)ABBINFull rights (Unknown)ABBPTLLPFull rights
(Primary)ABBYFull rights (Unknown)ABCCFull rights (Primary)ABCCNYFull rights 
(Unknown)ABCJORFull rights (Primary)ABDHFull rights (Unknown)ABERDEENFull rights (Unknown) 
ABINGDFull rights (Secondary)ABNEQUKFull rights (Unknown)ABPFull rights (Unknown)ABPALGEFull rights (Unknown)ABSAAMPFull rights 
(Primary)ABSOLUTFull rights (Secondary)ABSOLUTEFull rights (Support)ABUAUTHFull rights (Primary)ABUDHFull rights (Unknown)ACACIAFull rights   
(Primary)ACACIAMGFull rights (Primary)ACTALBKFull rights (Unknown)ADELGAFull rights (Secondary)ADELPHIFull rights (Primary)ADIGFull rights   
(Unknown)AEGAMFull rights (Unknown)AENEASFull rights (Unknown)AERIONFull rights 
(Primary)AFFILIAT [Sub-accounts] Full rights (Secondary)AGAMEMFull rights (Primary)AGFMFull rights (Secondary)AIGINVERFull rights (Primary)AIMFull rights 
(Support)AKERFull rights (Primary)AKITAASE

这就是我得到的:

bash-3.2$
-bash-3.2$
-bash-3.2$ echo "(Primary)ABDHFull" | sed -e 's/\([A-Z,a-z]\)//g'
()
-bash-3.2$

我想得到的只是一个ABDH ---然而当我使用它时,它会摆脱一切,只留下括号。

如何从“(小学)ABDHFull权利”获得ABDH 理想情况下,上面的列表应该看起来像这样 - 协同作用,就像老板一样。

7X7AM 99999 AAAM AAAMAHK AAAMNL AAMAH ABBIN ABBPTLLP ABBY ABCC ABCCNY ABCJOR

1 个答案:

答案 0 :(得分:2)

(根据要求)您需要:

echo "(Primary)ABDHFull" | sed -e 's/([^()]*)//g'.

你试图捕获一个,只有一个大写或小写字符或逗号,并用任何内容替换它