|
Vintage Computers Any vintage computer systems, calculators, video games etc., but with an emphasis on 1980s and earlier equipment. |
|
Thread Tools |
24th Aug 2019, 3:17 pm | #1 |
Octode
Join Date: Aug 2006
Location: Rye, East Sussex, UK.
Posts: 1,647
|
Word in file search utility, DOS
Years ago (20+!) there was a useful DOS utility which allowed one to search the location of a particular word in any number of files on the PC, similar to /S command, but in a far greater internal depth.
Can anyone remember what it's called... and is it still around in DOS or W3.1? |
24th Aug 2019, 6:10 pm | #2 |
Tetrode
Join Date: Feb 2016
Location: Guisborough, North Yorkshire, UK.
Posts: 80
|
Re: Word in file search utility, DOS
I never saw such a thing, as you describe it, but I wrote a somewhat limited version for my own use, which I still use.
This works on text files ONLY, in the current directory. It's looking for all 'hits' of a specified word. I use it mainly for following variables, keywords, etc in modules of source code. The prog defaults to *.c, but other things can be added to the command line like *.prg or *.txt, *.htm etc. The result is put to a file, comprising a header for each filename, then line number and (part) of the full text of the line. It's a DOS prog, so it's 8.3 filenames only. This has been causing me some trouble recently, so maybe I should change it? Any help? Geoff |
24th Aug 2019, 7:33 pm | #3 |
Heptode
Join Date: Jan 2009
Location: West Lothian, UK.
Posts: 762
|
Re: Word in file search utility, DOS
Was it not simply "Find" ?
https://sites.google.com/site/pcdosr...mands#TOC-FIND Pasted from the above site:- ___________________________________ FIND External - DOS 2.0 and above Searches for a text string in a file or files. FIND [/V] [/C] [/N] [/I] [/S] "string" [[drive:][path]filename[ ...]] /V Displays all lines NOT containing the specified string. /C Displays only the count of lines containing the string. /N Displays line numbers with the displayed lines. /I Ignores the case of characters when searching for the string. /S Search subdirectories also. "string" Specifies the text string to find. [drive:][path]filename Specifies a file or files to search. If a pathname is not specified, FIND searches the text typed at the prompt or piped from another command. /I is only available in DOS 5 and above. /S is only available in PC DOS 7. Also PC DOS 7 allows the use of wildcards in filenames while prior versions do not. _______________________________________
__________________
George |
24th Aug 2019, 8:26 pm | #4 |
Nonode
Join Date: Jan 2010
Location: Edinburgh, UK.
Posts: 2,008
|
Re: Word in file search utility, DOS
I used to use a program called Xtree Gold. Among the many file reading and manipulation functions was one that could search a selection of files for any chosen word or phrase.
Al
__________________
I won't tell you how I discovered that. |
24th Aug 2019, 10:19 pm | #5 |
Dekatron
Join Date: Jan 2012
Location: Brentwood, Essex, UK.
Posts: 5,349
|
Re: Word in file search utility, DOS
I paid 10p for a copy of "Field Guide to MS DOS 6.2" in a charity shop some years ago. A quick scan through it suggests that the commands FIND, FOR, and SORT, together with "piping" , can be used to search for text strings in a multiple files. Examples are given. Scans of the relevant pages attached.
No personal experience with using any of these commands. I have only used the book once, when the driver software for a LCD monitor for my WIN 98 PC managed to mess up the system so badly that I had to operate the PC in command mode, echoing the screen to a printer, to get it working again. I loved Xtree Gold: we used to use it at GEC in the early 1990's. I still have a copy of the software on a floppy, but I couldn't get it to run on my PC. Last edited by emeritus; 24th Aug 2019 at 10:24 pm. |
25th Aug 2019, 4:33 am | #6 |
Dekatron
Join Date: May 2006
Location: Invercargill, New Zealand
Posts: 3,458
|
Re: Word in file search utility, DOS
FIND will do that in a basic fashion.
Often I find it's useful to search for a particular word or phrase in a number of text files - specifically scripts for an accounting package I support, looking for things like a particular table or index name. FIND was always a little clunky for that, so I just wrote a little VB.NET program to do it - the guts of it is: Code:
Dim di As New DirectoryInfo(strPath) Dim files = From fi In di.EnumerateFiles(strType, SearchOption.AllDirectories) For Each fi As FileInfo In files Dim findstring = IO.File.ReadAllText(fi.FullName).ToLower If findstring.Contains(strFind) Then Console.WriteLine("Found in {0}", fi.FullName) End If Next |
25th Aug 2019, 8:47 am | #7 | |
Heptode
Join Date: May 2009
Location: Birmingham, West Midlands, UK.
Posts: 708
|
Re: Word in file search utility, DOS
Quote:
They did one later called 'Xtree for Windows' which was around in the Windows 3/95/era |
|
25th Aug 2019, 9:15 am | #8 |
Octode
Join Date: Aug 2006
Location: Rye, East Sussex, UK.
Posts: 1,647
|
Re: Word in file search utility, DOS
Thanks lads. I still use XTree on occasion but don't recall any 'find' facility... perhaps its only in Gold? I'll have a look and play with Find in DOS... meanwhile I'll continue searching for my old software catalogue!
|
25th Aug 2019, 3:42 pm | #9 |
Octode
Join Date: Aug 2006
Location: Rye, East Sussex, UK.
Posts: 1,647
|
Re: Word in file search utility, DOS
Back agin! Been playing with the FIND command but while it works fine entering a single, known file name, it doesn't handle a batch of files, or wild cards... but it does the job, laboriously, for my immediate needs.
How does XTGold differ - does it search through a batch of files and sub-directories? (I have the earlier XTree Pro). Barry |
25th Aug 2019, 5:55 pm | #10 |
Dekatron
Join Date: May 2008
Location: Derby, UK.
Posts: 7,735
|
Re: Word in file search utility, DOS
That sounds like the `grep` command in Unix. I'm fairly sure someone ported GNU grep (a popular Free and Open Source implementation of `grep`) to MS-DOS a long time ago.
__________________
If I have seen further than others, it is because I was standing on a pile of failed experiments. |
25th Aug 2019, 6:57 pm | #11 |
Dekatron
Join Date: Jan 2012
Location: Brentwood, Essex, UK.
Posts: 5,349
|
Re: Word in file search utility, DOS
Page 74 of the attachment I posted shows you how to do a wildcard search by combining FOR and FIND.
|
25th Aug 2019, 9:32 pm | #12 | |
Dekatron
Join Date: May 2006
Location: Invercargill, New Zealand
Posts: 3,458
|
Re: Word in file search utility, DOS
Quote:
Code:
for %f in (*.doc) do find /n /i "text" %f |
|
26th Aug 2019, 9:40 am | #13 |
Octode
Join Date: Aug 2006
Location: Rye, East Sussex, UK.
Posts: 1,647
|
Re: Word in file search utility, DOS
Thanks Arjoll, your "for %f in (*.doc)...." etc works fine, except for one problem... screen scrolling speed! There does not appear to be a 'by page' command (/p, |more etc or indeed ScrollLock on the keyboard) which works.
While it merrily flashes through all those files not containing the selected text, by the time it finds one which does, it is too late to hit 'Pause' - the file name having scrolled off the screen! Is there a way of scrolling page by page, or slowing down the scroll speed, or going back a page?? |
26th Aug 2019, 10:45 am | #14 |
Moderator
Join Date: Jan 2003
Location: Ipswich, Suffolk, IP4, UK.
Posts: 21,289
|
Re: Word in file search utility, DOS
From what I remember you enter " | more" (note leading space) at the end of the command line and then use the space bar to step to the next page.
__________________
Graham. Forum Moderator Reach for your meter before you reach for your soldering iron. |
26th Aug 2019, 10:50 am | #15 |
Dekatron
Join Date: Apr 2012
Location: Wiltshire, UK.
Posts: 14,007
|
Re: Word in file search utility, DOS
What you could do is redirect the output to a file, then use your editor-of-choice to view the file.
If you issue the command then put "> C:\junkfile.txt" on the end, the output of your command will end up in c:\junkfile.txt for your later perusal. See https://www.robvanderwoude.com/redirection.php |
26th Aug 2019, 11:51 am | #16 |
Dekatron
Join Date: May 2006
Location: Invercargill, New Zealand
Posts: 3,458
|
Re: Word in file search utility, DOS
Unfortunately piping through MORE as Graham suggested won't work here - it'll do the pipe on each individual iteration of FIND, not on the whole run.
G6Tanuki is close, but use >> file.txt instead - that will append each run to the file. With a single > you'll overwrite with each run and only ever get the results for the first file. Trying something like: More < for %f in... May work as well, but I am not on my PC so can't check. I'll have a look in the morning NZ time. |
26th Aug 2019, 3:43 pm | #17 |
Octode
Join Date: Aug 2006
Location: Rye, East Sussex, UK.
Posts: 1,647
|
Re: Word in file search utility, DOS
Thanks,
While G6Tanuki's and Arjoll's improved save-to-file trick now makes it a manageable tool through EDLIN, I'm finding that it is very selective in reporting those files that contain the target word(s), correctly spelt, ignoring several files which I know for certain do! I'm mystified... but at any rate this fundamental unreliability makes the whole exercise rather pointless and I'm frankly better of using my instinct and the basic Type and Edit commands! Progress, eh?! Anyway thanks very much for all your help - much appreciated as ever. Back to square one... Barry |
26th Aug 2019, 8:25 pm | #18 |
Nonode
Join Date: Oct 2014
Location: West Midlands, UK.
Posts: 2,181
|
Re: Word in file search utility, DOS
Xtree works ( to a limited extent on up to ,I think W7(,but there's a modern version that has no file length called Ztree.
|
26th Aug 2019, 9:36 pm | #19 |
Dekatron
Join Date: Feb 2007
Location: Lynton, N. Devon, UK.
Posts: 7,088
|
Re: Word in file search utility, DOS
Xtree gold is what I remember too. But it is limited in its ability to search within each file, as it has to be able to open and read each one to do so. I seem to remember it couldn't understand WordPerfect 5.1 files, for instance, so didn't find the search text if it was in one of these files.
|
27th Aug 2019, 1:04 am | #20 | |
Dekatron
Join Date: May 2006
Location: Invercargill, New Zealand
Posts: 3,458
|
Re: Word in file search utility, DOS
Quote:
|
|