Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Piping commands is causing "command not found" error

  1. #1
    Join Date
    Aug 2008
    Beans
    6

    Piping commands is causing "command not found" error

    Hello,

    I have just installed Ubuntu 8.04 LTS and i am encountering the following problem:
    Code:
    $ history | grep lib
    bash: grep: command not found
    However, grep exists. Running
    Code:
    $ which grep
    /bin/grep
    The same problem exists when i run for example,
    Code:
    $ history | less
    bash: less: command not found
    Would someone have an explanation and a solution ?

    Kind Regards

  2. #2
    Join Date
    Mar 2008
    Location
    City of Pines
    Beans
    3,585

    Re: Piping commands is causing "command not found" error

    What displays when your issue the command below on your terminal:

    Code:
    echo $PATH
    Steady movement is more important than speed, much of the time. So long as there is a regular progression of Stimuli to get your mental hooks into, there is room for lateral movement. Once this begins, its rate is a matter of discretion.

  3. #3
    Join Date
    Jul 2008
    Location
    Sandvika, Norway
    Beans
    406
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Piping commands is causing "command not found" error

    Quote Originally Posted by vnuckcha View Post
    Hello,

    I have just installed Ubuntu 8.04 LTS and i am encountering the following problem:
    Code:
    $ history | grep lib
    bash: grep: command not found
    However, grep exists. Running
    Code:
    $ which grep
    /bin/grep
    The same problem exists when i run for example,
    Code:
    $ history | less
    bash: less: command not found
    Would someone have an explanation and a solution ?

    Kind Regards
    grep doesn't find "lib".
    less doesn't find its command. I don't remember less much, but it's probably missing a parameter. Try less --help and grep --help.

    Probably nothing wrong with grep or less. They both give you some feedback.
    If it works, FIX IT! (Bill Gates)


  4. #4
    Join Date
    Aug 2008
    Beans
    6

    Re: Piping commands is causing "command not found" error

    Hello,

    This is the output of the PATH variable:
    Code:
    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    As you can see, /bin is in the path.

    :/

  5. #5
    Join Date
    Aug 2008
    Beans
    6

    Re: Piping commands is causing "command not found" error

    Hi Ingeva,

    The errors mean that the commands (grep and less) cannot be located on the filesystem.

    The
    Code:
    $echo $PATH
    command that iaculallad asked me to check is to verify if those commands are indeed on the system path.

    Hope this helps towards your understanding of the problem.

    Kind Regards

  6. #6
    Join Date
    Mar 2008
    Location
    City of Pines
    Beans
    3,585

    Re: Piping commands is causing "command not found" error

    Quote Originally Posted by vnuckcha View Post
    Hello,

    This is the output of the PATH variable:
    Code:
    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    As you can see, /bin is in the path.

    :/
    Could you check your /etc/profile file if we are similar with what I'm posting below:

    Code:
    # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
    # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
    
    if [ -d /etc/profile.d ]; then
      for i in /etc/profile.d/*.sh; do
        if [ -r $i ]; then
          . $i
        fi
      done
      unset i
    fi
    
    if [ "$PS1" ]; then
      if [ "$BASH" ]; then
        PS1='\u@\h:\w\$ '
        if [ -f /etc/bash.bashrc ]; then
    	. /etc/bash.bashrc
        fi
      else
        if [ "`id -u`" -eq 0 ]; then
          PS1='# '
        else
          PS1='$ '
        fi
      fi
    fi
    
    umask 022
    Code above is from Hardy's.
    Steady movement is more important than speed, much of the time. So long as there is a regular progression of Stimuli to get your mental hooks into, there is room for lateral movement. Once this begins, its rate is a matter of discretion.

  7. #7
    Join Date
    Oct 2007
    Location
    Chennai, India
    Beans
    3,804
    Distro
    Ubuntu Development Release

    Re: Piping commands is causing "command not found" error

    Quote Originally Posted by vnuckcha View Post
    Code:
    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    What happens of you only use less without piping?

    Can you also check your permissions for /bin and /usr/bin as well as the commands themselves?
    Code:
    ls -ld /bin
    ls -ld /usr/bin
    ls -l `which grep`
    ls -l `which less`
    Cheers,PRShah
    Make your own: Ubuntu, Kubuntu, Xubuntu, Mythbuntu All-in-One Live DVD
    "I never make mistakes; I thought I did, once.. but I was wrong."

  8. #8
    Join Date
    Sep 2006
    Location
    Solihull/Piraeus (UK/GR)
    Beans
    421
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Piping commands is causing "command not found" error

    Does:

    Code:
    history |grep lib
    (i.e. without the space after the pipe character) work?

    This can sometimes be a locale problem in that the space character sent by your locale settings in X is not interpreted as whitespace (or something like that). What are your language settings?
    Last edited by wdaniels; August 28th, 2008 at 08:07 AM.

  9. #9
    Join Date
    Jul 2008
    Location
    Sandvika, Norway
    Beans
    406
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Piping commands is causing "command not found" error

    Quote Originally Posted by vnuckcha View Post
    Hi Ingeva,
    The errors mean that the commands (grep and less) cannot be located on the filesystem.
    I'm sorry, you are right.
    grep and less are SO standard that they should just always be installed,
    so I assumed that they were just used wrongly. My mistake.
    If it works, FIX IT! (Bill Gates)


  10. #10
    Join Date
    Aug 2008
    Beans
    6

    Re: Piping commands is causing "command not found" error

    Quote Originally Posted by iaculallad View Post
    Could you check your /etc/profile file if we are similar with what I'm posting below:

    Code:
    # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
    # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
    
    if [ -d /etc/profile.d ]; then
      for i in /etc/profile.d/*.sh; do
        if [ -r $i ]; then
          . $i
        fi
      done
      unset i
    fi
    
    if [ "$PS1" ]; then
      if [ "$BASH" ]; then
        PS1='\u@\h:\w\$ '
        if [ -f /etc/bash.bashrc ]; then
    	. /etc/bash.bashrc
        fi
      else
        if [ "`id -u`" -eq 0 ]; then
          PS1='# '
        else
          PS1='$ '
        fi
      fi
    fi
    
    umask 022
    Code above is from Hardy's.
    Hi,

    There is no difference from the /etc/profile listing you gave and the one on my computer.

    I did a diff and compared line by line manually

    Kind Regards

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •