View previous topic :: View next topic |
Author |
Message |
Marcus613 n00b
Joined: 28 Feb 2024 Posts: 19
|
Posted: Sat Mar 02, 2024 4:46 am Post subject: Replacing all lines of a command output |
|
|
Hi
I'm using genlop to display a message when emerging a package. The command I use is "genlop -ci".
When no package is being emerged, the following two lines are returnes:
Code: | !!! Error: no working merge found.
(the -c option only works if there is an ongoing compilation, see manpage) |
But in that case I want ton display nothing, an empty string: ""
I did this with the following command (witch display two empty lines in that case):
Code: | genlop -ci | awk 'NR==1 && /^!!! Error/ {print ""} NR!=1' | awk 'NR==1 && /^\(the -c option/ {print ""} NR!=1' |
Is there a better way to do this and tell awk (or something else) "if first line starts with this patern then replaces every lines with this patern" ? |
|
Back to top |
|
|
freke Veteran
Joined: 23 Jan 2003 Posts: 1029 Location: Somewhere in Denmark
|
Posted: Sat Mar 02, 2024 8:16 am Post subject: |
|
|
Alternatively you could try from app-portage/portage-utils, it defaults to no output if no running emerge.
Output when emerging is a little different though Code: | 2024-03-02T09:14:39 >>> app-portage/eix: 7 seconds... (1 of 1) ETA: 55 seconds |
|
|
Back to top |
|
|
CaptainBlood Advocate
Joined: 24 Jan 2010 Posts: 3864
|
Posted: Sat Mar 02, 2024 9:38 am Post subject: |
|
|
I've just tested genlop -ci which returned $?=0 when no current emerge build process.
Maybe upstream could improve that...
I've removed app-portage/genlop package in favor of qlop from app-portage/portage-utils as it may additionally remove dev-perl/Date-Manip depending on remaining package dependency tree.
Thks 4 ur attention, interest & support. _________________ USE="-* ..." in /etc/portage/make.conf here, i.e. a countermeasure to portage implicit braces, belt & diaper paradigm
LT: "I've been doing a passable imitation of the Fontana di Trevi, except my medium is mucus. Sooo much mucus. " |
|
Back to top |
|
|
Leonardo.b Guru
Joined: 10 Oct 2020 Posts: 308
|
Posted: Sat Mar 02, 2024 9:38 am Post subject: |
|
|
In awk, you can call exit to terminate early without printing anything.
Otherwise, to work with multiple lines, you may look into getline builtin function. |
|
Back to top |
|
|
Marcus613 n00b
Joined: 28 Feb 2024 Posts: 19
|
Posted: Sat Mar 02, 2024 9:45 am Post subject: |
|
|
Leonardo.b wrote: | In awk, you can call exit to terminate early without printing anything.
Otherwise, to work with multiple lines, you may look into getline builtin function. |
Could you show how to do that please ?
qlop seems interesting but it looks like you need privileges to run it.
But I'll definitely check this one |
|
Back to top |
|
|
|