i have to search the files that don't have pattern:-
*abc*.txt and *xyz*.txt
Please suggest a way to list all the files which don't have the above patterns.
You can use an extended glob, such as the following:
!(*@(abc|xyz)*.txt) In ksh, this works by default, whereas in bash you need to first enable a shell option:
shopt -s extglob ! negates the match and @ matches any of the pipe-separated patterns.
This pattern expands to the list of files that don't match *abc*.txt or *xyz*.txt, so you can pass it to another command to see the result, e.g. printf:
printf '%s\n' !(*@(abc|xyz)*.txt) bash: !: event not found!(*@(abc|xyz)*.txt) -- This is called a subpattern in ksh.. Use ksh to execute it..With find command:
find -type f ! \( -name '*abc*.txt' -o -name '*xyz*.txt' \) find: illegal option -- t find: [-H | -L] path-list predicate-listfind allow you to omit the path(s) in which to search, defaulting to .. Yours apparently does not; try find . -type f ....You can use the --hide=PATTERN option with ls. In your case it would be
ls --hide="*abc*.txt" --hide="*xyz*.txt" illegal option -- every time you enter a command with an option. Which OS are you using? Any special bash config?--hide is a non-standard option to ls so it's perfectly reasonable to expect that it doesn't exist on some systems.