Subject: | |
From: | |
Reply To: | |
Date: | Fri, 18 Sep 2009 02:35:42 +0200 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
At 13:13 -0700 UTC, on 2009-09-17, [log in to unmask] wrote:
> I'm trying to find every line in a 2800-line pipe delimited file that
> contains: |(TRAV)|
[...]
> The version below returns every line of the file.
I get your result when the input file contains Mac linebreaks[*]. Change the
input file's linebreaks to unix linebreaks[*], and the below works fine:
set input to quoted form of POSIX path of (choose file)
do shell script "grep '|(TRAV)|' " & input
The clue was given by using grep's -n flag, which prints line numbers for
every line found. With the Mac line endings in the input file, grep printed
only a single line number, indicating that it considered the file to contain
a single line. And since that single line does contain the needle, it was
given as the result.
[*] With "Mac linebreaks" and "unix linebreaks" I'm using BBEdit/TextWrangler
terminology.
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
|
|
|