PDA

View Full Version : grep a string in a file


odo
12-12-2003, 06:54 AM
In the previous version the string:
RUN ' fgrep test N:\dirlist > N:\results'
searching 'test' in dirlist file and write the results in the results file.
In OSDD12 seems this not work.
Is it true?
Is there another command in substituction?
Thanks at all.
Bye

H.annes
12-14-2003, 11:03 PM
Hello Odo,

with RUN you start a UNIX-command, so this does not depend on the ME10-version - it works fine in 12.01.
But it will not work on Windows!

Hannes

odo
12-15-2003, 12:51 AM
Hello Hannes,
Sorry but I forget to tell you.
My system run on UNIX to serve Workstation and PC.
My grep string run until I pass to OSDD12.
Have you any idea that help me???
Bye & Thanks

Yannick Rouat
12-15-2003, 02:29 AM
Hello odo

You can bypass OS type by using ME10 macro language

local read_line
open_infile 9 "N:\dirlist"
open_outfile 8 del_old "N:\results"
loop
read_file 9 read_line
exit_if (read_line = "END-OF-FILE")
if ((pos(upc read_line) "TEST") <> 0)
write_file 8 read_line
end_if
end_loop
close_file 8
close_file 9

regards

clausb
12-15-2003, 05:01 AM
RUN ' fgrep test N:\dirlist > N:\results'


This is a most peculiar command string. odo tells us that it is meant to run on a UNIX box, yet the string contains Windows-style drive letters and backslashes instead of UNIXish forward slashes! I wonder how that code could ever have worked on an HP-UX box....

Claus

odo
12-15-2003, 06:18 AM
Hello all
Can I sure you !
I have open on the same PC an Me10Ver10.20 & OSDD12 with the same string (see previous mail).
The old version, create a file results in the
"N:\" connection.
The new version, instead ,create a file empty in the same connection.
The two programs point at the same Unix B11.00 box.
Bye & Thanks

clausb
12-15-2003, 06:35 AM
Alright, so this means you are running OSDD on a Windows PC, and the command just happens to write to a file which is located on a UNIX drive mounted via Samba or NFS.

If the fgrep command fails, the first thing I would check is whether or not that command is in OSDD's search path. Note that fgrep is NOT a standard Windows command, i.e. you must have installed UNIXish command-line utilities somewhere on your PC. Make sure that PATH points to the installation directory of those utilities.

Alternatively, simply use the DOS equivalent to the UNIX grep family: For instance, try something like


RUN ' findstr test N:\dirlist\* > N:\results'

odo
12-15-2003, 07:27 AM
Hello Clausb
It's all like you write!!!!!
So I points the utycmds in the right paths and now all runs (Also "findstr").
Thanks at all & Merry Xmas.