LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-25-2008, 12:56 PM   #1
allohakdan
LQ Newbie
 
Registered: Sep 2003
Location: The Hills of West Virginia
Distribution: Ubuntu/Debian
Posts: 22

Rep: Reputation: 15
anything piped to grep returns "(standard input)"... why?


For some reason I cannot pipe anything to grep on one of my machines. All it gives back is "(standard input)"...

- some examples -

$ ps ax | grep "ps ax"
(standard input)

$ ls | grep -v myfile
(standard input)

I thought it might be something in my .bashrc file, but the only thing i had aliased grep to was "grep -color". To add to my frustration, using grep itself does work...

$ grep "something" myfile
myfile

I tried searching around, but so far I have no answers...

This machine is actually a virtual machine i have been using as a mobile test server (for about a year now) for testing out code and scripts on occasion... but recently i have been using it for more day to day work and thats when i realized there was a problem

Does anyone have an idea what is causing this or how I could fix it?

Thanks
 
Old 09-25-2008, 01:07 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
That's a bit on the odd side.

What do you get from 'type grep'?

Dave
 
Old 09-25-2008, 04:23 PM   #3
darthaxul
Member
 
Registered: Aug 2008
Distribution: Gentoo; Funtoo
Posts: 201

Rep: Reputation: 18
woa

I had something similar.
I think its either because the files are binary or they are not complete/fragmented?
 
Old 09-26-2008, 01:43 PM   #4
allohakdan
LQ Newbie
 
Registered: Sep 2003
Location: The Hills of West Virginia
Distribution: Ubuntu/Debian
Posts: 22

Original Poster
Rep: Reputation: 15
$ type grep
grep is aliased to `grep -n -color'
 
Old 09-27-2008, 12:28 PM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Try doing 'unalias grep' and see if it works.

Dave
 
Old 09-27-2008, 12:34 PM   #6
jgallo
Member
 
Registered: Sep 2008
Posts: 39

Rep: Reputation: 15
any luck?

I had experienced this recently and am just not on the terminal where i had the problem, jsut wondering if these solutions work

Linux Archive

Last edited by jgallo; 10-12-2008 at 01:52 AM.
 
Old 09-27-2008, 01:17 PM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Small tip for you: if you have an alias that's the same as the original command name, i.e. aliased to add flags or whatnot, you can use a backslash in front of the command to temporarily bypass the alias and revert to the default behavior.

e.g. if you have the alias ls="ls --all", then typing "\ls" will give you the original non-aliased "ls" output.

Likewise, typing "\grep" should allow you to bypass the alias in the case above. And it certainly appears to be the alias that's the problem, because I tried setting it up myself, and it does the same thing for me. But it works when I bypass the alias.


Edit: I think I see the problem. "grep -color" is not a valid command. The proper command is "grep --color=[when]", where "[when]" is either never, always, or auto.

Last edited by David the H.; 09-27-2008 at 01:28 PM.
 
Old 09-28-2008, 12:42 PM   #8
allohakdan
LQ Newbie
 
Registered: Sep 2003
Location: The Hills of West Virginia
Distribution: Ubuntu/Debian
Posts: 22

Original Poster
Rep: Reputation: 15
$ ps ax | \grep "px ax"
7224 pts/4 R+ 0:00 px ax
7225 pts/4 R+ 0:00 grep ps ax

Thanks for the help! I was not aware that I could add the \ before my aliased commands to bypass the alias - nice trick. And yes you were both correct, the aliased syntax was the problem. I had noticed the syntax wasn't normal earlier but then wrote it off as not hurting anything because I _could_ grep individual files... next time I will be more careful
 
Old 09-28-2008, 01:02 PM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Glad to help. And I myself wasn't aware that there was a "color" option for grep, so I learned something new also.
 
  


Reply

Tags
grep


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I "cat" or "grep" a file to ignore lines starting with "#" ??? callagga Linux - Newbie 7 08-16-2013 06:58 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
standard grep question. "The parameter list is too long" antis Linux - General 1 07-03-2007 01:43 AM
Bios config: "ahci" or "standard ide" for a sata drive ? Danodare Slackware 1 11-05-2006 12:31 AM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 03:11 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration