|
Home > Archive > Unix Shell > February 2007 > search a characters in a text files
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
search a characters in a text files
|
|
| Unix_shell 2007-02-22, 7:19 am |
| Hi,
I want to search a list of numbers in a file by a shell script, file1:
32568899
33114567
33646897
in anothers files file2:
test1 33114567
test2 32568899
test3 33646897
Thanks for your Help.
if it is possible to get the result of search in a file.
Regards.
| |
| Paul E. Lehmann 2007-02-22, 7:19 am |
| Unix_shell wrote:
> Hi,
>
> I want to search a list of numbers in a file by
> a shell script, file1:
>
> 32568899
> 33114567
> 33646897
>
> in anothers files file2:
>
> test1 33114567
> test2 32568899
> test3 33646897
>
> Thanks for your Help.
>
> if it is possible to get the result of search in
> a file.
>
> Regards.
these wouldn't be social security numbers, would
they?
| |
| Michael Tosch 2007-02-22, 7:19 am |
| Unix_shell wrote:
> Hi,
>
> I want to search a list of numbers in a file by a shell script, file1:
>
> 32568899
> 33114567
> 33646897
>
> in anothers files file2:
>
> test1 33114567
> test2 32568899
> test3 33646897
>
Quick and dirty:
fgrep -f file1 file2
More precise, recommended for social security numbers ;-)
awk 'FILENAME=="file1" {s[$1]=1; next} s[$2]==1' file1 file2
--
Michael Tosch @ hp : com
| |
| Bruce Barnett 2007-02-22, 7:19 am |
| "Paul E. Lehmann" <someone@anywhere.com> writes:
> Unix_shell wrote:
>
[vbcol=seagreen]
> these wouldn't be social security numbers, would
> they?
Not enough digits.
--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.
|
|
|
|
|