How to get files without certain strings in their files names (reverse of *string*) on Linux?

To get files with certain string in their file names, it is quite straightforward:

ls *string*

However, how to do the reverse one: how to get files without certain strings in their files names on Linux?

You can get a list of file names by a combination of find and xargs as follows:

find . ! -name '.' -and ! -name '*string*' | xargs

or by ls and grep as follows:

ls | grep -v string | xargs

Similar Posts

  • 禁止对话框关闭按钮和Alt+F4

    在某些情况下我们需要防止用户单击窗口的标题栏中的关闭按钮关闭 MFC 应用程序。可以删除窗口的WS_SYSMENU 样式, 但是,这样最大化最小化和还原按钮也被删除,并且无法添加。 这是Windows的设计依据。 可以通过禁用关闭按钮来模拟没有关闭按钮的窗口。 在 WM_CREATE 消息处理程序中禁用关闭按钮。使用下面的代码: CMenu *pSysMenu = GetSystemMenu(FALSE); ASSERT(pSysMenu != NULL); VERIFY(pSysMenu->RemoveMenu(SC_CLOSE, MF_BYCOMMAND)); 这样删除之后关闭按钮变为灰色,用户无法点击。但是使用Alt+F4仍然可以关闭程序。要将此功能也禁用需要重载CDialog的OnSysCommand方法。代码如下: void MyDlg::OnSysCommand( UINT nID, LPARAM lParam ) { if ( ( nID & 0xFFF0 ) == IDM_ABOUTBOX ) { CAboutDlg dlgAbout; //if you have an about dialog dlgAbout.DoModal(); } //add the following code else if…

  • How to list all running system service on Linux Mint 17.1?

    How to list all running system service on Linux Mint 17.1? You can use initctl to list all services: initctl list Read more: Running Ephemeral Docker Containers – Automatically Remove a Docker Container After Running It Script: Running Commands on a List of Servers Finding Which Package Provides a File in Ubuntu Linux and Linux…

Leave a Reply

Your email address will not be published. Required fields are marked *