就像我有这样一个数据

1 -> (abc
 2-> abc)

一个有左括号,两个有右括号.

I am expecting like I have txt file I have both mistakes while entering and missing want to echo all the occurrence of opening but absence of closing while another one is if only closing present. I am using bash code but it only shows for occurrence of opening but absence of closing parenthesis my code is grep -E '^[^()]*\([^()]*$|^[^()]*[^()]*\([^()]*$' and this shows only result for ( abc
but not for abc). please help me out Thanks.

推荐答案

也许这个正则表达式就是您要找的

grep -E '^[^()]*[()]{1}[^()]*$'

Linux相关问答推荐

C++17:G++8.5版似乎无法正确生成无符号64位伪随机整数

为什么我的Linuxshell 程序有时找不到它刚刚创建的文件?

是否有例外情况需要在.gitconfig中使用?

在Linux中随机化txt文件但保证不重复行

X86 程序集 - struct 点 - 存储/返回不正确?

如何使用netcat为DPDK实例提供输入?

有必要注意非错误提示吗?好像没有找到包裹‘***’?

如何在守护进程中使用 popen() 和 pclose() 获取通过管道执行的 shell 命令的正确退出代码?

std::system 使用什么Shell?

如何在 AWS Linux 服务器上实现虚拟主机?

未找到框架.NETFramework,Version=v4.7.1的参考程序集

BASEDIR 环境变量未正确定义

如何构建在 Android 上运行的本机(命令行)可执行文件?

KDE 桌面效果中的 OpenGL 和 XRender 有什么区别?

打印当前一周的星期一的日期(在 bash 中)

Linux命令删除.git文件夹以外的所有文件?

nvm:无法卸载当前活动的 node 版本

从文本文件中删除奇数行或偶数行

GNU Octave 方法对矩阵中的每个项目进行操作.octave arrayfun(...)示例

在linux中根据内容拆分文件