grep or fgrep ?

Luis lemsx1 at
Sun Sep 24 02:38:53 UTC 2006

On 9/23/06, Thilo Six <T.Six at> wrote:
> Richard wrote the following on 23.09.2006 19:09:
> > Thanks for the try, but your command did not work.
> >
> >
> > rick at 64bit:/usr/share/services/searchproviders$ sudo  fgrep "Keys" *desktop |
> > {sed|cut|awk|sort|uniq} > /dev/shm/my_list.log
> > bash: {sed: command not found
> > cut: you must specify a list of bytes, characters, or fields
> > Try `cut --help' for more information.
> > bash: uniq}: command not found
> [hint]
> this command example wasn´t meant to be copy & pasted into terminal.
> Instead you will need to edit it to your needs.
> [/hint]

Well said.

> <snip>
> >> man sed
> >> man cut
> >> man sort
> >> man awk
> >> man uniq
> These tools are really powerful and to handle them right makes the
> difference between a noob and an expert. Personally i belong to ther
> former.  ;)

Ouch. Well, if you need a copy-n-paste script to do something
specific, you should simply word it:

I need to grep for foo strings from files ending in bar, and then I
need the output to look like ""

In other words, provide an example of how your output should look like.

I don't mind giving the exact copy-n-paste line, but, it would be
nicer if the user asking for this would take some time to read the
manual pages of all the standard (aka POSIX) commands I mentioned in
the original post. The purpose is to become autonomous and help others
when the time comes to do that.


In a related (but shameless plug) subject, I did a script called
"" that does what fgrep/grep does but recursively. In other
words, you can do: "regex_or_string_to_find" "pattern_of_files"

And the output will include what you are looking for using this format:

filename [linenumber]: line_containing_string

An example is:

$> cd /usr/share/applications
$> keys '\.desktop'
keybinding.desktop [76]: Comment=Assign shortcut keys to commands
keybinding.desktop [92]: Comment[en_CA]=Assign shortcut keys to commands
keybinding.desktop [93]: Comment[en_GB]=Assign shortcut keys to commands
easytag.desktop [12]: Comment[nl]=EasyTAG is een programma voor het
bewerken van tags van MP2-, MP3-, FLAC-, Ogg Vorbis, MusePack en
Monkeys Audio-bestanden. Dit gebeurt in een verzorgde GTK+-omgeving.

You can get this script from:

Luis Mondesi
*NIX Guru

"We think basically you watch television to turn your brain off, and
you work on your computer when you want to turn your brain on" --
Steve Jobs in an interview for MacWorld Magazine 2004-Feb

No .doc:

More information about the ubuntu-users mailing list