POV-Ray : Newsgroups : povray.off-topic : Context switching : Re: Context switching Server Time
5 Sep 2024 05:25:16 EDT (-0400)
  Re: Context switching  
From: Invisible
Date: 22 Apr 2010 06:42:28
Message: <4bd02814@news.povray.org>
>> No, I mean... I thought grep can only search within a single file (as 
>> can any decent text editor). I didn't realise it can search multiple files.
> 
>   You tell it which files it should search, like:
> 
>     grep 'abc' file1.txt file2.txt file3.txt

I didn't know you could do that. (Then again, I've never used grep, so...)

>   Of course if you are in a command line shell, you can use the shell to aid
> you in specifying more files by using a pattern, eg:
> 
>     grep 'abc' file*.txt
> 
>   (Note that it's the shell that expands the pattern to actual file names,
> not grep.)

Heh. I didn't know the shell could do that either. (Although you didn't 
specify *which* shell - Unix has several...)

>> (I'm still having trouble thinking up a use-case for that. About the 
>> only thing I can think of is trying to find out which header file 
>> defines a particular symbol or something.)
> 
>   'grep' is one of the most used utilities in Unix systems. It's quite handy
> for many, many things. The reason why it's useful is because as it prints
> the found results to stdout, you can pipe them to something else, which may
> then do something with those results, and so on. Using 'grep' as part of such
> a chain of commands is pretty common.
> 
>   Of course 'grep' is useful all in itself as well, if you want to find files
> which contain a certain string.

I'm still not seeing what's so useful about being able to search a file 
for something.

Now, I suppose if you were trying to script something, being able to 
pipe output from another command into grep so that it can grab a 
particular substring that you can then pipe to something else might be 
useful. But then, if *I* wanted to do something like that, I wouldn't 
script it. I'd write a real program, not a script.

>> If it's a small file, you can search it just be scrolling through it and 
>> looking with your eyes. You don't need an automated search facility. The 
>> only real reason to use an automated search is if there's too much data 
>> to hunt through manually.
> 
>   What if you have 50 small files?

Maybe that's the difference. I never have 50 small files.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.