The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   grep command not found ! (http://hintsforums.macworld.com/showthread.php?t=99636)

horacioemilio 03-11-2009 08:23 AM

grep command not found !
 
Hi,

I switched recently to os x and so. I usually connect to linux machines via ssh and sometimes I get strange errors when I try to do "history | grep monday " like " grep, command not found ". This is very strange. Of course if I am loggend from a linux machine and I connect to this one and I do the same, I do not get this error.

And this error seems to occurr randomly. And also happens with some other commands like "last", etc

Regards

Horacio

hayne 03-11-2009 12:07 PM

See the "command not found" & "shell config" sections of this Unix FAQ.

(It sounds like you have your "dot" files setting an inappropriate PATH.)

horacioemilio 03-12-2009 10:35 AM

Hi,

that is not my problem. I checked on the linux machine which I connect to, that the commands "grep" etc are in the path, and they are.

The strange problem is the following:

- if I just do "grep", this is ok

grep
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.

but if I use pipes there are errors;

ps -ef |*grep whatever
-bash: *grep: command not found

Any ideas ?

hayne 03-12-2009 11:30 AM

Quote:

Originally Posted by horacioemilio (Post 523727)
that is not my problem. I checked on the linux machine which I connect to, that the commands "grep" etc are in the path, and they are.

Sorry - I didn't understand that you were running these commands on the Linux machine - I thought you were remote-logged into OS X.

Quote:

but if I use pipes there are errors;

ps -ef |*grep whatever
-bash: *grep: command not found
What is that "*" for ?!?
That is not the normal construct.
To pipe the output of 'ps -ef' into 'grep', you use:
ps -ef | grep whatever

horacioemilio 03-12-2009 12:18 PM

sorry, the * was a mistake of mine

I use the right thing:

ps -ef | grep whatever

horacioemilio 03-18-2009 09:52 AM

it is really a pity that the shell in mac os x does NOT really work like it should

Mikey-San 03-18-2009 10:27 AM

Quote:

Originally Posted by horacioemilio (Post 524628)
it is really a pity that the shell in mac os x does NOT really work like it should

I do what you're trying to do many times a day. You're not telling us something important, or you're missing something subtle on your setup. Trust me, grep works from piped input on Mac OS X.

horacioemilio 03-18-2009 10:29 AM

on mac os x it works for me without problems.

if you read what i write before, when i log on to a linux machine, then i get the error there.

but that's not a problem of the remote linux machine because if a connect there from another linux machine, then no problem a t all

grüsse

hayne 03-18-2009 11:30 AM

Quote:

Originally Posted by horacioemilio (Post 524628)
it is really a pity that the shell in mac os x does NOT really work like it should

Oh - I thought that the problem was solved after you realized your mistake in post #5.

Please show us the command you are running and the error messages (verbatim).

horacioemilio 03-18-2009 11:33 AM

everything is described before, anyway
1- from mac os x i open the terminal and log to a linux machine using ssh
2- once logged there i type;
ps -ef | grep hijodeputa
3- i get;
-bash: grep: command not found

if i connect from linux to linux of i am directly on the screen of that linux machine, i do not get this error

btw, it happens randomly with another commands like "more", etc

hayne 03-18-2009 11:39 AM

Quote:

Originally Posted by horacioemilio (Post 524647)
everything is described before, anyway
1- from mac os x i open the terminal and log to a linux machine using ssh
2- once logged there i type;
ps -ef | grep hijodeputa
3- i get;
-bash: grep: command not found

if i connect from linux to linux of i am directly on the screen of that linux machine, i do not get this error

btw, it happens randomly with another commands like "more", etc

Sorry - but I don't want a description - I want a copy/paste from the Terminal window. Otherwise we can't be sure that you aren't mis-describing the situation (like the * above).
So please reproduce the problem and then copy/paste the whole contents of your Terminal window here so we can see.
And before (or after) you run that command, please run the following commands (and of course include these commands & output in what you show us):

echo $PATH
which grep
command -V grep

horacioemilio 03-18-2009 11:49 AM

Code:

sanchez@intsanchez:~> ps -ef |*grep hijodeputa
-bash: *grep: command not found
sanchez@intsanchez:~> echo $PATH
/bin:/home/sanchez/work/software/moe/moe/bin:/home/sanchez/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin:/data/horacio/software/moe/moe/bin
sanchez@intsanchez:~> which grep
/bin/grep
sanchez@intsanchez:~> command -V grep
grep is /bin/grep
sanchez@intsanchez:~>


Hal Itosis 03-18-2009 11:56 AM

Quote:

Originally Posted by horacioemilio (Post 524651)
anchez@intsanchez:~> ps -ef |*grep hijodeputa
-bash: *grep: command not found

Hello???:rolleyes:

horacioemilio 03-18-2009 11:58 AM

yes ?????????????

Hal Itosis 03-18-2009 12:00 PM

eres pendejo?

horacioemilio 03-18-2009 12:01 PM

only english please, so everybody can understand it

horacioemilio 03-18-2009 12:02 PM

sorry, when pasting my previous output, there is an asterik before the "grep" which i never type, i do not why it appears here

Code:

sanchez@intsanchez:~> ps -ef | grep hijodeputa
-bash:  grep: command not found
sanchez@intsanchez:~> echo $PATH
/bin:/home/sanchez/work/software/moe/moe/bin:/home/sanchez/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib64/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/lib/qt3/bin:/data/horacio/software/moe/moe/bin
sanchez@intsanchez:~> which grep
/bin/grep
sanchez@intsanchez:~> command -V grep
grep is /bin/grep
sanchez@intsanchez:~>


horacioemilio 03-18-2009 12:04 PM

the last post is the right one

trevor 03-18-2009 12:11 PM

Is that an actual copy/paste from the Terminal, or did you just edit the transcript to remove the asterisks?

It looks like you just edited the transcript to remove the asterisks, since there's an extra space before 'grep' in the
Code:

-bash:  grep: command not found
error message that would not normally be there.

Trevor

horacioemilio 03-18-2009 12:17 PM

now i realize about everything

for some reason, when i type at the terminal

ps -ef |*grep something

there is some kind of hidden asterisk there

but if i delete that space between the pipe and grep and add one or two spaces, then the problem is gone

ok, i dont understand anything, but i chekced it out on different machines and the problem is gone, who cares about the reason :-P

hayne 03-18-2009 12:26 PM

Quote:

Originally Posted by horacioemilio (Post 524665)
now i realize about everything

for some reason, when i type at the terminal

ps -ef |*grep something

there is some kind of hidden asterisk there

but if i delete that space between the pipe and grep and add one or two spaces, then the problem is gone

ok, i dont understand anything, but i chekced it out on different machines and the problem is gone, who cares about the reason

I would care about the reason - something is going wrong.

One thing I don't understand - when you say:
Quote:

when i type at the terminal

ps -ef |*grep something
what keys are you pressing on the keyboard? Specifically, what keys are you pressing after you type the 'f' of "ps -ef" ?
It looks like you are typing a space and then a vertical bar (|) and then an asterisk and then a 'g'.
Are you typing something after the vertical bar before you type the 'g' ?

Or maybe (most likely) the problem is with the vertical bar itself.
What key are you pressing to get the vertical bar?
What type of keyboard do you have on your Mac?
Is the vertical bar on the key at the right-side just above the Return key?
What model of Mac do you have?
What language is set for keyboard input?

Papillon 10-18-2011 06:22 AM

Even though this post is very old. It helped me by giving the hint with the hidden asterisk.

This hidden character is triggered when the <alt>-key is not released before pressing the <space>-key. The german keyboard layout uses the <alt>-key to enter a pipe.

<space> != <alt><space>

Maybe its a Problem with the Keyboard Layout.


All times are GMT -5. The time now is 05:31 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.