If you want to retrieve the filename without extension, then you have to provide the file extension as SUFFIX with `basename` command. Here, the extension is “. txt”.
Windows Explorer - Advanced Query Syntax You can use a for /f loop iterating the output of a dir command with the /B and /A-D parameters, and then use some conditional if logic to only output files without any extensions using substitutions for the iterated files in the specified directory.
Or without (
and the need to escape it:
find . -not -name "*.exe" -not -name "*.dll"
and to also exclude the listing of directories
find . -not -name "*.exe" -not -name "*.dll" -not -type d
or in positive logic ;-)
find . -not -name "*.exe" -not -name "*.dll" -type f
find . ! \( -name "*.exe" -o -name "*.dll" \)
$ find . -name \*.exe -o -name \*.dll -o -print
The first two -name options have no -print option, so they skipped. Everything else is printed.
You could do something using the grep command:
find . | grep -v '(dll|exe)$'
The -v
flag on grep
specifically means "find things that don't match this expression."
one more :-)
$ ls -ltr total 10 -rw-r--r-- 1 scripter linuxdumb 47 Dec 23 14:46 test1 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:40 test4 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:40 test3 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:40 test2 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:41 file5 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:41 file4 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:41 file3 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:41 file2 -rw-r--r-- 1 scripter linuxdumb 0 Jan 4 23:41 file1 $ find . -type f ! -name "*1" ! -name "*2" -print ./test3 ./test4 ./file3 ./file4 ./file5 $
Unix find command reference
find /data1/batch/source/export -type f -not -name "*.dll" -not -name "*.exe"
Linux/OS X:
Starting from the current directory, recursively find all files ending in .dll or .exe
find . -type f | grep -P "\.dll$|\.exe$"
Starting from the current directory, recursively find all files that DON'T end in .dll or .exe
find . -type f | grep -vP "\.dll$|\.exe$"
Notes:
(1) The P option in grep indicates that we are using the Perl style to write our regular expressions to be used in conjunction with the grep command. For the purpose of excecuting the grep command in conjunction with regular expressions, I find that the Perl style is the most powerful style around.
(2) The v option in grep instructs the shell to exclude any file that satisfies the regular expression
(3) The $ character at the end of say ".dll$" is a delimiter control character that tells the shell that the filename string ends with ".dll"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With