LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Fortune - ignore option (https://www.linuxquestions.org/questions/linux-newbie-8/fortune-ignore-option-4175604794/)

RobertLM78 04-27-2017 03:17 PM

Fortune - ignore option
 
I like fortune, and it's fun having them come up when I open a terminal window, but yesterday I was given a fortune (under wisdom of all things) from the turd Arthur Balfour. I WILL NOT have that a$$hat in my fortunes.

Reading the man page, I saw that there is an -i option for ignore, which appears to be used with the -m option (pattern). I've tried a few things, but I'm really not sure how to use this two options together. I've tried:

Code:

$ fortune -i -m Balfour
$ fortune -im Balfour
$ fortune -m Balfour -i

Which mostly just gives the listing of fortunes that match the pattern. So how do I ignore a pattern, and is there some way to confirm that a pattern has been put on ignore?

norobro 04-27-2017 04:40 PM

I think you'll have to edit the file(s) to remove the quotes that you don't want to see.

Simple enough to do. Using the wisdom file as an example:
Quote:

...
%
Nothing is so firmly believed as that which we least know.
-- Michel de Montaigne
%
Nothing matters very much, and few things matter at all.
-- Arthur Balfour

%
Of all men's miseries, the bitterest is this:
to know so much and have control over nothing.
-- Herodotus
%
...
Edit /usr/share/games/fortunes/wisdom to remove the Balfour quote.
Then run "strfile wisdom" to create the .dat file (see man strfile)

RobertLM78 04-27-2017 05:24 PM

Quote:

Originally Posted by norobro (Post 5703190)
I think you'll have to edit the file(s) to remove the quotes that you don't want to see.

Simple enough to do. Using the wisdom file as an example:


Edit /usr/share/games/fortunes/wisdom to remove the Balfour quote.
Then run "strfile wisdom" to create the .dat file (see man strfile)

Awesome - that's perfect! I'd thought about just editing the wisdom file, but then there was that .dat file there... which I assume is the one actually used by fortune. I'll have to learn about 'strfile'.... didn't realize re-creating that file would be that easy! Thank you norobro!

Edit: Just so that you know - it worked perfectly! Thank you very much!

jamison20000e 04-27-2017 06:18 PM

So if you're the problem with the world will adding you to my ignore list (like a little girl) work? :rolleyes:

ondoho 04-28-2017 01:46 AM

recompiling the database?
not sure about that.

first of all, the '-i' option means
Quote:

Originally Posted by man fortune
-i Ignore case for -m patterns.

that means: balfour == Balfour.

I think what you want is either not possible with fortune, or you have to come up with some regex that says "NOT Balfour":
Quote:

Originally Posted by man fortune
-m pattern
Print out all fortunes which match the basic regular expression pattern. The syntax
of these expressions depends on how your system defines re_comp(3) or regcomp(3),
but it should nevertheless be similar to the syntax used in grep(1).

also i'm worried about "all" in the first sentence...?

norobro 04-28-2017 08:13 AM

Quote:

Originally Posted by ondoho (Post 5703384)
also i'm worried about "all" in the first sentence...?

The way that I interpret that is if you could use "NOT Balfour" (I couldn't get that to work) you would get all of the other entries in the file.

The first line in the Description in the man page:
Quote:

When fortune is run with no arguments it prints out a random epigram.

RobertLM78 04-29-2017 02:14 PM

Quote:

Originally Posted by jamison20000e (Post 5703240)
So if you're the problem with the world will adding you to my ignore list (like a little girl) work? :rolleyes:

Very Ⓚo$her!! Are you sure I'm not a snowflake?


All times are GMT -5. The time now is 08:50 AM.