Can this one-liner be made more compact? [SOLVED]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

Can this one-liner be made more compact? [SOLVED]

#1 Post by musher0 »

Hello, all.

Can this one-liner be made more compact?

Code: Select all

ps -e > ps.txt && grep -io "ROX-Filer" ps.txt && rm -f ps.txt
If so, I can't see it just now. :cry:

Thanks in advance.

musher0
Last edited by musher0 on Wed 16 Jan 2013, 23:30, edited 1 time in total.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#2 Post by rcrsn51 »

What is the objective?

How about

Code: Select all

ps -e | grep -io "ROX-Filer"

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Hi, rcrsn51.

Thanks. I'm trying to find the condition to launch or not a ROX panel. If the name of the panel can be listed with ps, I will do away with the dummy file I am currently using.

With the help of your idea, I suppose my line should now be this:

Code: Select all

ps f | grep -io "en-bas"
  • ("en-bas" being the very bland name of my ROX panel at the bottom of my screen and
    "ps f" rather than "ps -e", because "f" displays a full line with all the parameters used by ROX-filer -- so we can discover if a ROX panel is active or not)
Only annoyance now is that "en-bas" appears twice. (hehe)

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#4 Post by rcrsn51 »

musher0 wrote:Only annoyance now is that "en-bas" appears twice.

Code: Select all

 grep -m 1

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#5 Post by musher0 »

Gee, you're quick! :)

So, efficient line is :

Code: Select all

ps f | grep -iom 1 "en-bas"
Many thanks! :)

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#6 Post by musher0 »

Hello again.

Perhaps I marked [SOLVED] a little soon.
The ps command does not diagnose ROX-Filer fully.
The telling file is /root/.config/rox.sourceforge.net/ROX-Filer/panels.
(Thanks to "some1" for reminding me.)
So we use that file instead. The following works well:

Code: Select all

#!/bin/sh
# /root/my-applications/bin/barre-bas.sh
# Cacher ou afficher une barre ROX en bas de l'écran.
# Hide or display a ROX panel at the bottom of the screen.
# musher0, 17 janv. 2013.
####
cd /root/.config/rox.sourceforge.net/ROX-Filer
 [ "`grep -iom 1 \"en-bas\" panels`" == "en-bas" ] && rox -b= || rox -b=en-bas &

# (Pour la commodité de la chose, on peut mettre un icone servant de commutateur sur l'écran.)
# (For ease of use, we can put a switch icon on the screen.)
TWYL

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply