cmd - findstr not bringing back correct files -


i running windows command findstr search specific sting in .ini files. command running findstr /i /s /m /c:\output *.ini looking string \output. following output command

etc\billdirfile.ini etc\doc1dirfile.ini etc\environ.ini_20150902_0944 etc\environ.ini_20150903_1035 

i expect file etc\environ.ini show in list not. when rerun command added wildcard @ end findstr /i /s /m /c:\output *.ini* out put follows.

etc\billdirfile.ini etc\doc1dirfile.ini etc\environ.ini etc\environ.ini.bak etc\environ.ini_20150901_1021 etc\environ.ini_20150901_1050 etc\environ.ini_20150901_1431 etc\environ.ini_20150901_1433 etc\environ.ini_20150901_1438 etc\environ.ini_20150902_0944 etc\environ.ini_20150902_0954 etc\environ.ini_20150903_1035 etc\environ.ini_20150903_1042 etc\environ.ini_20150903_1344 etc\environ.ini_20150922_1305 

i have 2 questions based on output.

1) why without additional wildcard i.e. *.ini @ end environ.ini file expect see not show ? checked name of file there no additional spaces or characters @ end.

2) why these 2 files

etc\environ.ini_20150902_0944 etc\environ.ini_20150903_1035 

show without added wildcard @ end i.e. without *.ini*. expect see .ini files only.

also testing on machine

findstr /i /s /m /c:\output *.ini etc\billdirfile.ini etc\doc1dirfile.ini etc\environ.ini etc\environ.ini_20150825_1521 

the findstr command finds etc\environ.ini file without issue. both machines running server 2012 r2 , same. appreciated.

thanks,

mack

when using in batch file file name of console application findstr without file extension , without complete path, command line processor searches first in current directory , next in directories defined in environment variable path findstr* , checks if found file has file extension defined in environment variable pathext.

to see current values of path , pathext run in command prompt window set path lists environment variables starting path in name.

as ntfs file system driver returns file names in alphabetic order, findstr.bat used first command processor found first prior findst.exe perhaps existing in same directory not wanted. way: internal commands of cmd.exe echo used if no executable file found having name echo , file extension listed in pathext.

so findstr in batch file on 1 of 2 computers not result in executing findstr.exe in system32 directory of windows, in using different findstr.* found in 1 of directories in path having file extension listed in pathext.

it more safe specify in batch files console applications findstr.exe full path , file extension, i.e. use %systemroot%\system32\findstr.exe instead of findstr.

you should check if there file name findstr file extension listed in pathext in directory listed in path. batch file checkpath jason faulkner useful find out if there findstr.bat or findstr.com or finstr.exe , in directory of path found first.

the answer second question why *.ini environ.ini_20150902_0944 , environ.ini_20150903_1035 processed findstr is:

the short names of files environ~3.ini , environ~4.ini.

(the numbers different on computer.)

the kernel function used findstr , dir searching files given pattern takes short file names account , not long file names. run dir /s /x *.ini , see files found *.ini because of match on long or short file name.

i have no idea why environ.ini not listed on first output. perhaps can find out reason looking on short names of *.ini in directory etc.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -