Re: Pipes
Re: Pipes
- Subject: Re: Pipes
- From: Graff <email@hidden>
- Date: Sun, 11 Jan 2004 00:56:05 -0500
First of all, "$1" resolves to a variable named 1. Doing [2] gives me
a listing of everything in the working directory, to find out why I
checked what $1 was set to by doing:
echo "$1"
It turned out that the variable $1 was set to a linefeed and was thus
matching every line from the ls command.
If you want to search for a literal $1 you should do this:
ls -la | grep -i '\$1'
You need the \ before the $ because a $ is a metacharacter that
represents the end of the line in a regular expression and so the \
escapes that metacharacter and makes it into a normal dollar sign.
So basically things are most likely acting screwy because you are
running into some murky waters where things are a bit undefined. What
is it that you are trying to grep here? If you explain what pattern
you are trying to match then we can see what is best to use.
- Ken
On Jan 10, 2004, at 11:44 PM, Marc K. Myers wrote:
Could someone tell me why this works:
[1] ps -acx | grep -i "$1"
and this doesn't?
[2] ls -la | grep -i "$1"
This *will* work:
[3] ls -la | grep -i "${1}"
and this will work
[4] ps -acx | grep -i "${1}"
but I can't figure out why [2] won't.
Marc [01/10/04 11:43:56 PM]
PS: The numbers in brackets are not part of the commands.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
- Follow-Ups:
- Re: Pipes
- From: "Marc K. Myers" <email@hidden>
References: | |
| >Pipes (From: "Marc K. Myers" <email@hidden>) |