1

I want to use less as a pager for mysql client. I want to add -F to force quit for short outputs. But I can't combine both correctly.

root@jupiter:/# mysql -p -u root -h localhost --pager=less -F
mysql: unknown option '-F'

is there a way?

Anyway I have some newbie trouble with less:

cat oo.txt            # shows me some short garbage
cat oo.txt |less -F   # nothing happens,    I expect show and quit.
less -F oo.txt        # nothing happens,    I expect show and quit.
less oo.txt           # shows the short garbage and waits for q keystroke (or whatever)

I am connected via putty if that matters.

2 Answers 2

1

I think you forgot to quote:

mysql -p -u root -h localhost --pager='less -F'

-F gets passed to mysql instead of less when you don't pass less -F as a single string.

2
  • fine, that is the way!!!, put inside quotes! remains to me a correct flag to show & exit for small stuff Apr 15, 2015 at 20:59
  • 1
    @LuisSiquot try: less -F --no-init (suggestion from unix.stackexchange.com/q/107315/70524).
    – muru
    Apr 15, 2015 at 20:59
1

From man less:

   -F or --quit-if-one-screen
          Causes less to automatically exit if the entire file can be
displayed on the first screen.

So, less -F file.txt will make less exit automatically without showing anything, if the content of file.txt can be displayed on the first screen.

Here is a test:

$ cat test.txt 
Hello WORLD!
Hallo world!

$ less -F test.txt 
$ 

** See muru's answer for the other mistake you have made.

4
  • the point is can less show & exit? other flag? what is -F useful for? thanks for your help Apr 15, 2015 at 20:56
  • You want a cat-like behavior in those cases?
    – heemayl
    Apr 15, 2015 at 21:02
  • yes, cat-like for short stuff Apr 15, 2015 at 21:04
  • Then like muru already said, you need to use -X or --no-init i.e. less -FX file.txt
    – heemayl
    Apr 15, 2015 at 21:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .