Results 1 to 6 of 6

Thread: grep not working

  1. #1
    Join Date
    Sep 2010
    Beans
    4

    grep not working

    hello I'm attempting to learn how to use the CLI with GNOME Ubuntu and am working through some tutorials but grep doesn't seem to be working.
    After typing "grep stuff" in a directory containing a file called "stuff" the cursor goes to a new blank line and just flashes until I have to end it.
    Anyone know what could be happening here? Find doesn't seem to do much either!
    cheers, pete
    below is what occurs

    Code:
    pete@pete-laptop:~$ cd ~
    pete@pete-laptop:~$ ls
    bashrc           examples.desktop  Music             podsleuth  smgTkLib
    Calibre Library  firefox           nano.save         Public     stuff
    Desktop          LocalApps         package_list.txt  README     Templates
    Documents        mary1             Pictures          shared     Videos
    Downloads        mary2.txt         Podcasts          smgLib
    pete@pete-laptop:~$ grep mary1
    ^Z
    [4]+  Stopped                 grep --color=auto mary1
    pete@pete-laptop:~$ grep stuff
    ^Z
    [5]+  Stopped                 grep --color=auto stuff
    Last edited by CharlesA; November 1st, 2010 at 03:45 PM. Reason: added code tags.

  2. #2
    Join Date
    Oct 2010
    Location
    Argentina
    Beans
    73
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: grep not working

    You need to run it like this:

    Code:
    ls | grep stuff
    The | symbol is a pipeline, this way you are passing the output of the ls command, as an input to the grep command, so, grep takes that text and searches for "stuff" in it.

  3. #3
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: grep not working

    janpol hit it dead-on.

    Also, Ctrl + Z stops a job, If you want to kill something that is actively running, you hit Ctrl + C.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  4. #4
    Join Date
    Sep 2010
    Beans
    4

    Re: grep not working

    cheers guys, thanks alot, not as important but why does this tutorial not say that then? http://www.linux.org/lessons/beginner/l9/lesson9b.html
    and would anyone know of more accurate ones?
    thanks again
    pete

  5. #5
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: grep not working

    That tutorial is searching the file "Mary" for a string of text.

    You are trying to search for "stuff" without telling grep where to look (which is why you get the ">" prompt).
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  6. #6
    Join Date
    Nov 2007
    Location
    Surrey, England
    Beans
    259
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: grep not working

    You can read the documentation for grep by typing this into a terminal window:

    Code:
    man grep
    Use the down arrow to scroll down the help file and hit the 'q' key to quit and return to the prompt.

Tags for this Thread

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
  •