Re: TaskWrapper commands with "*.txt" for example
Re: TaskWrapper commands with "*.txt" for example
- Subject: Re: TaskWrapper commands with "*.txt" for example
- From: John Nairn <email@hidden>
- Date: Wed, 11 Dec 2002 10:55:02 -0700
I did try that, but it had two problems
1. I could not get it to work. The problem might have been associated
with the last argument being \;. Here \ is an escape character for the
shell and I think the ; might be special too? When all args were put
into a TaskWrapper it always gave some error (I tired "\;" and just
";").
2. The other problem is this expands to several independent commands.
For example
find . -name "*.txt? -exec grep findme {} \;
for a directory have file1.txt and file2.txt, is the same as two
separate commands
grep findme file1.txt
grep findme file2.txt
When grep has a single file, it does not print the file name where a
match was made. It can be mostly fixed by using -H with grep, but then
you always get a file name printed even when searching only a single
file.
If I could get it working, it might still be better route than my shell
command method.
On Wednesday, December 11, 2002, at 10:08 AM, Andrew Hobbs wrote:
You could execute the command as
find . -name "*.txt" -exec grep findme {} \;
That uses find to expand the glob and calls grep on each file found.
It has the other advantage of working on huge numbers of matches.
Just doing a grep findme *.txt on a directory with thousands of *.txt
will cause a "Too many arguments" error.
YMMV, etc. There's probably a cleaner way but this just sprang to
mind.
Andrew
On Wednesday, December 11, 2002, at 11:50 AM, John Nairn wrote:
I am using a TaskWrapper to launch a Unix task from a Cocoa
application. I have done it many time before without any trouble.
Today I was using a command that might reference many files such as
grep findme *.txt
but "*.txt" does not get expanded into all files matching that
expression. I guess that is a shell task. Is there a good way to have
such a command executed such that arguments are expanded?
I just tried a TaskWrapper with arguments
0: /bin/csh
1: -c
2: grep findme *.txt
and it might be working. Is this the right way or is there something
else?
------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page: http://www.mse.utah.edu/~nairn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page:
http://www.mse.utah.edu/~nairn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.