You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

-bash: cat: command not found (or grep)

Hi, Strange things:




i3: okn$ ls -R | grep -h "dof" | cat > dtext.txt

-bash: cat: command not found


or then I get this:


i3: okn$ find . -type f -print | grep -c

-bash: grep: command not found


but this is not happening all the time, i remember grep or cat did work once or twice...



What's going on here?


OS 10.7.4; repaired permissions


Any assistance much appreciated!


/ bw, Omar KN

Mac OS X (10.7.2)

Posted on Jul 9, 2012 2:52 PM

Reply
Question marked as Top-ranking reply

Posted on Jul 9, 2012 3:04 PM

You have corrupted your PATH environment variable which tells the bash where to look for commands.


Start looking in one of the following files, as that is most likely where you were messing with PATH


.bash_profile

.bash_login

.profile

.bashrc


Fix your PATH and then restart your Terminal session.


If necessary, use commands such as


/bin/ls -a

/bin/cat .filename

/usr/bin/nano .filename


Message was edited by: BobHarris

19 replies

Jul 16, 2012 9:27 AM in response to oktan

That's because you inserted an invisible character after the pipe ! option-space actually puts an invisible character. You type too fast and don't release your finger from the option key after making the pipe and pressing the space bar.


Workaround : release all keys before entering a space after a pipe 🙂

Jul 21, 2012 7:42 AM in response to BobHarris

>cat -vte will display invisible and control characters


Tried that, thank you, but nothing strange here.



Also I took away a SHORTKEY which I had in Things, a Mac OS X app,

where the shortkey was ALT - SPACE.


Well maybe when writing the pipe, which is done on my keyboard with: ALT - 7 and when lifting the fingers off the 7 to press the SPACE, something was too fast, possibly.


Maybe related is the fact that on quite a few occasions on my webpages, empty spaces (but even between letters) something produces an " Â ", ie. an A with a roof on it, like you need in French, â = circonflex.

Now I never wrote this  -thing, it just introduces itself into the text sometimes.


Anyway, I'm glad for all the help I got and can now use again the grep and other commands in the terminal!


bw, Omar K N

Jul 21, 2012 12:21 PM in response to Omar.KN

If you're encountering random characters in your data input, it would appear you have a problem with your keyboard, with OS X, or with your Mac hardware. If the random caracters are arising in your data output, then you're looking at some sort of problem arising somewhere between where your data is stored and the OS X rendering; with OS X or with your storage.


Swap your keyboard for a different USB keyboard, and see if things start working.

-bash: cat: command not found (or grep)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.