grep - ignore empty values [closed]
I am wondering is there an easy way to ignore search result output lets say like a $pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' -e 'argument: '
in this case the output is giving if argument has values or if it doesn't.
The $pacmd list-modules
input format snippet:
...
index: 5#<---not this index because the module's module-cli-protocol-unix arg is empty
name: <module-cli-protocol-unix>#<---not this name though its name is module-cli-protocol-unix but still its arg is empty
argument: <>#<---not this module's arg because it is empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 6
name: <module-switch-on-port-available>
argument: <>
used: -1
load once: no
properties:
index: 7
name: <module-udev-detect>
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Detect available audio hardware and load matching drivers"
module.version = "10.0"
index: 8
name: <module-bluetooth-policy>
argument: <>
used: -1
load once: yes
properties:
module.author = "Frédéric Dalleau, Pali Rohár"
module.description = "Policy module to make using bluetooth devices out-of-the-box easier"
module.version = "10.0"
index: 9 #<---this one because it is the module-cli-protocol-unix index
name: <module-cli-protocol-unix>#<---this one because its name is module-cli-protocol-unix
argument: <sink_name=module-cli_>#<---this one because module's arg is not empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 10
name: <module-bluez5-discover>
argument: <>
used: -1
load once: yes
properties:
module.author = "João Paulo Rechi Vita"
module.description = "Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers"
module.version = "10.0"
...
As a final output it would be nice to have something like this:
index: N
name: <module-cli-protocol-unix>
argument: <not-empty-value>
According to the exact input example the sorted output should be as:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
...but the solution should be dynamic in case another module with non-empty args is about to be init-ed...
So my question is how to make grep output name if argument has non-empty value?
And, yes, it would be nice to have a non-script solution... ;).
EDIT
I just tried the solution as pacmd list-modules | grep -B2 'argument: <[^>]' | grep -Po 'index:.*|name: <module-cli-protocol-unix>'
but the output is following:
index: 0
index: 1
name: <module-cli-protocol-unix>
index: 25
index: 26
name: <module-cli-protocol-unix>
...which is odd cause it gives 4 index-es for 2 modules but it must have one index per module :S
linux grep pulseaudio
closed as unclear what you're asking by roaima, Mr Shunz, Scott, Thomas, Haxiel Mar 7 at 18:50
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
|
show 8 more comments
I am wondering is there an easy way to ignore search result output lets say like a $pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' -e 'argument: '
in this case the output is giving if argument has values or if it doesn't.
The $pacmd list-modules
input format snippet:
...
index: 5#<---not this index because the module's module-cli-protocol-unix arg is empty
name: <module-cli-protocol-unix>#<---not this name though its name is module-cli-protocol-unix but still its arg is empty
argument: <>#<---not this module's arg because it is empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 6
name: <module-switch-on-port-available>
argument: <>
used: -1
load once: no
properties:
index: 7
name: <module-udev-detect>
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Detect available audio hardware and load matching drivers"
module.version = "10.0"
index: 8
name: <module-bluetooth-policy>
argument: <>
used: -1
load once: yes
properties:
module.author = "Frédéric Dalleau, Pali Rohár"
module.description = "Policy module to make using bluetooth devices out-of-the-box easier"
module.version = "10.0"
index: 9 #<---this one because it is the module-cli-protocol-unix index
name: <module-cli-protocol-unix>#<---this one because its name is module-cli-protocol-unix
argument: <sink_name=module-cli_>#<---this one because module's arg is not empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 10
name: <module-bluez5-discover>
argument: <>
used: -1
load once: yes
properties:
module.author = "João Paulo Rechi Vita"
module.description = "Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers"
module.version = "10.0"
...
As a final output it would be nice to have something like this:
index: N
name: <module-cli-protocol-unix>
argument: <not-empty-value>
According to the exact input example the sorted output should be as:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
...but the solution should be dynamic in case another module with non-empty args is about to be init-ed...
So my question is how to make grep output name if argument has non-empty value?
And, yes, it would be nice to have a non-script solution... ;).
EDIT
I just tried the solution as pacmd list-modules | grep -B2 'argument: <[^>]' | grep -Po 'index:.*|name: <module-cli-protocol-unix>'
but the output is following:
index: 0
index: 1
name: <module-cli-protocol-unix>
index: 25
index: 26
name: <module-cli-protocol-unix>
...which is odd cause it gives 4 index-es for 2 modules but it must have one index per module :S
linux grep pulseaudio
closed as unclear what you're asking by roaima, Mr Shunz, Scott, Thomas, Haxiel Mar 7 at 18:50
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
7
Please provide an example of source data, so we can try out your commands against a known input.
– roaima
Feb 23 at 0:20
@roaima you mean the result output? The full output is the pulseaudio's$pacmd list-modules
– user390525
Feb 23 at 0:28
This is conjecture at best, but I suspect you are after$pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' | grep -e 'argument:
– iruvar
Feb 23 at 3:53
@iruvar in this case the argument also outputs asargument: <>
if it is empty so how to skip if there isargument: <>
also output expected?
– user390525
Feb 24 at 2:48
@user390525 To be able to test solutions to this issue, we would need to know what the input togrep
might look like, and we also (for clarity) need to know what you expect to get as the result under different conditions. I have voted to close this question as "unclear" until such information is added.
– Kusalananda
Feb 24 at 10:26
|
show 8 more comments
I am wondering is there an easy way to ignore search result output lets say like a $pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' -e 'argument: '
in this case the output is giving if argument has values or if it doesn't.
The $pacmd list-modules
input format snippet:
...
index: 5#<---not this index because the module's module-cli-protocol-unix arg is empty
name: <module-cli-protocol-unix>#<---not this name though its name is module-cli-protocol-unix but still its arg is empty
argument: <>#<---not this module's arg because it is empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 6
name: <module-switch-on-port-available>
argument: <>
used: -1
load once: no
properties:
index: 7
name: <module-udev-detect>
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Detect available audio hardware and load matching drivers"
module.version = "10.0"
index: 8
name: <module-bluetooth-policy>
argument: <>
used: -1
load once: yes
properties:
module.author = "Frédéric Dalleau, Pali Rohár"
module.description = "Policy module to make using bluetooth devices out-of-the-box easier"
module.version = "10.0"
index: 9 #<---this one because it is the module-cli-protocol-unix index
name: <module-cli-protocol-unix>#<---this one because its name is module-cli-protocol-unix
argument: <sink_name=module-cli_>#<---this one because module's arg is not empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 10
name: <module-bluez5-discover>
argument: <>
used: -1
load once: yes
properties:
module.author = "João Paulo Rechi Vita"
module.description = "Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers"
module.version = "10.0"
...
As a final output it would be nice to have something like this:
index: N
name: <module-cli-protocol-unix>
argument: <not-empty-value>
According to the exact input example the sorted output should be as:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
...but the solution should be dynamic in case another module with non-empty args is about to be init-ed...
So my question is how to make grep output name if argument has non-empty value?
And, yes, it would be nice to have a non-script solution... ;).
EDIT
I just tried the solution as pacmd list-modules | grep -B2 'argument: <[^>]' | grep -Po 'index:.*|name: <module-cli-protocol-unix>'
but the output is following:
index: 0
index: 1
name: <module-cli-protocol-unix>
index: 25
index: 26
name: <module-cli-protocol-unix>
...which is odd cause it gives 4 index-es for 2 modules but it must have one index per module :S
linux grep pulseaudio
I am wondering is there an easy way to ignore search result output lets say like a $pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' -e 'argument: '
in this case the output is giving if argument has values or if it doesn't.
The $pacmd list-modules
input format snippet:
...
index: 5#<---not this index because the module's module-cli-protocol-unix arg is empty
name: <module-cli-protocol-unix>#<---not this name though its name is module-cli-protocol-unix but still its arg is empty
argument: <>#<---not this module's arg because it is empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 6
name: <module-switch-on-port-available>
argument: <>
used: -1
load once: no
properties:
index: 7
name: <module-udev-detect>
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Detect available audio hardware and load matching drivers"
module.version = "10.0"
index: 8
name: <module-bluetooth-policy>
argument: <>
used: -1
load once: yes
properties:
module.author = "Frédéric Dalleau, Pali Rohár"
module.description = "Policy module to make using bluetooth devices out-of-the-box easier"
module.version = "10.0"
index: 9 #<---this one because it is the module-cli-protocol-unix index
name: <module-cli-protocol-unix>#<---this one because its name is module-cli-protocol-unix
argument: <sink_name=module-cli_>#<---this one because module's arg is not empty
used: -1
load once: yes
properties:
module.author = ""
module.description = ""
module.version = "10.0"
index: 10
name: <module-bluez5-discover>
argument: <>
used: -1
load once: yes
properties:
module.author = "João Paulo Rechi Vita"
module.description = "Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers"
module.version = "10.0"
...
As a final output it would be nice to have something like this:
index: N
name: <module-cli-protocol-unix>
argument: <not-empty-value>
According to the exact input example the sorted output should be as:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
...but the solution should be dynamic in case another module with non-empty args is about to be init-ed...
So my question is how to make grep output name if argument has non-empty value?
And, yes, it would be nice to have a non-script solution... ;).
EDIT
I just tried the solution as pacmd list-modules | grep -B2 'argument: <[^>]' | grep -Po 'index:.*|name: <module-cli-protocol-unix>'
but the output is following:
index: 0
index: 1
name: <module-cli-protocol-unix>
index: 25
index: 26
name: <module-cli-protocol-unix>
...which is odd cause it gives 4 index-es for 2 modules but it must have one index per module :S
linux grep pulseaudio
linux grep pulseaudio
edited Mar 5 at 5:17
user390525
asked Feb 23 at 0:13
user390525user390525
62111
62111
closed as unclear what you're asking by roaima, Mr Shunz, Scott, Thomas, Haxiel Mar 7 at 18:50
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by roaima, Mr Shunz, Scott, Thomas, Haxiel Mar 7 at 18:50
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
7
Please provide an example of source data, so we can try out your commands against a known input.
– roaima
Feb 23 at 0:20
@roaima you mean the result output? The full output is the pulseaudio's$pacmd list-modules
– user390525
Feb 23 at 0:28
This is conjecture at best, but I suspect you are after$pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' | grep -e 'argument:
– iruvar
Feb 23 at 3:53
@iruvar in this case the argument also outputs asargument: <>
if it is empty so how to skip if there isargument: <>
also output expected?
– user390525
Feb 24 at 2:48
@user390525 To be able to test solutions to this issue, we would need to know what the input togrep
might look like, and we also (for clarity) need to know what you expect to get as the result under different conditions. I have voted to close this question as "unclear" until such information is added.
– Kusalananda
Feb 24 at 10:26
|
show 8 more comments
7
Please provide an example of source data, so we can try out your commands against a known input.
– roaima
Feb 23 at 0:20
@roaima you mean the result output? The full output is the pulseaudio's$pacmd list-modules
– user390525
Feb 23 at 0:28
This is conjecture at best, but I suspect you are after$pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' | grep -e 'argument:
– iruvar
Feb 23 at 3:53
@iruvar in this case the argument also outputs asargument: <>
if it is empty so how to skip if there isargument: <>
also output expected?
– user390525
Feb 24 at 2:48
@user390525 To be able to test solutions to this issue, we would need to know what the input togrep
might look like, and we also (for clarity) need to know what you expect to get as the result under different conditions. I have voted to close this question as "unclear" until such information is added.
– Kusalananda
Feb 24 at 10:26
7
7
Please provide an example of source data, so we can try out your commands against a known input.
– roaima
Feb 23 at 0:20
Please provide an example of source data, so we can try out your commands against a known input.
– roaima
Feb 23 at 0:20
@roaima you mean the result output? The full output is the pulseaudio's
$pacmd list-modules
– user390525
Feb 23 at 0:28
@roaima you mean the result output? The full output is the pulseaudio's
$pacmd list-modules
– user390525
Feb 23 at 0:28
This is conjecture at best, but I suspect you are after
$pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' | grep -e 'argument:
– iruvar
Feb 23 at 3:53
This is conjecture at best, but I suspect you are after
$pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' | grep -e 'argument:
– iruvar
Feb 23 at 3:53
@iruvar in this case the argument also outputs as
argument: <>
if it is empty so how to skip if there is argument: <>
also output expected?– user390525
Feb 24 at 2:48
@iruvar in this case the argument also outputs as
argument: <>
if it is empty so how to skip if there is argument: <>
also output expected?– user390525
Feb 24 at 2:48
@user390525 To be able to test solutions to this issue, we would need to know what the input to
grep
might look like, and we also (for clarity) need to know what you expect to get as the result under different conditions. I have voted to close this question as "unclear" until such information is added.– Kusalananda
Feb 24 at 10:26
@user390525 To be able to test solutions to this issue, we would need to know what the input to
grep
might look like, and we also (for clarity) need to know what you expect to get as the result under different conditions. I have voted to close this question as "unclear" until such information is added.– Kusalananda
Feb 24 at 10:26
|
show 8 more comments
4 Answers
4
active
oldest
votes
pacmd list-modules |
grep -B2 'argument: <[^>]' |
grep -B1 -A1 'name: <module-cli-protocol-unix>'
- The
-B
option prints lines before a match as well as the match itself - the
-A
option prints lines after a match - if whitespace is a problem, it can be stripped with sed, for example
So the process is:
- list all the modules
- filter on non-zero arguments
- then filter on the corect module name
Thank you for your reply. Is there a way to have-e 'index: '
which is related to the selected module? I just triedpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but seems like it outputs all existing modules index-es instead of the found one :P
– user390525
Feb 25 at 4:02
read the grep documentation on the meaning of-B
and-v
– jhnc
Feb 25 at 4:06
2
pacmd list-modules | grep -B2 'argument: <[^>]' | grep -B1 name: <module-cli-protocol-unix>'
– jhnc
Feb 25 at 4:09
I just edited my question please see it.
– user390525
Feb 25 at 4:20
See my amended comment
– jhnc
Feb 25 at 4:26
|
show 1 more comment
It will be unclear until you provide some sample, but you can try:
pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>'
It will first reject all strings having empty values for argument and then will only grep those lines which have name: <module-cli-protocol-unix>
.
Thank you. Seems like it is very nearby the point. I also tried to include index with the expressionpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but it outputs all modules index-es not the found ones :(
– user390525
Feb 25 at 4:13
@user390525 you can use one more pipe and then usegrep -e 'index: '
.
– Prvt_Yadv
Feb 25 at 8:46
add a comment |
If you are considering argument: <>
to be an empty argument then this could work
pacmd list-modules | grep -B2 '^argument: <..*>' | grep -E '^(index|name|argument):'
Output from sample:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
what grep version do you use? I have v3.0 now installed.
– user390525
Mar 3 at 16:00
No, I want the argument to be NOT EMPTY; I mean it should have values like aargument: <some_param=value etc>
– user390525
Mar 3 at 16:03
SO GIVE SOME EXAMPLES SO WE DONT HAVE TO KEEP GUESSING
– roaima
Mar 3 at 16:53
OK. I edited my question adding comments to the exact input source the module(s) which is about to be extracted; But the final solution should be dynamic in case a similar module is about to be init-ed...
– user390525
Mar 3 at 17:24
add a comment |
Tried with below command and worked fine
command
pacmd list-modules|awk '/index: [0-9]/||/name: <.*>/||/argument: <.*?>/{print $0}'
Thank you for your reply. I am not sure how to integrate the solution if to use the$pacmd list-modules
utility command instead of the filename?
– user390525
Mar 2 at 18:35
I am not sure how to convert it to grep? Could you provide the solution with grep util?
– user390525
Mar 3 at 15:58
KIndly check edited posted
– Praveen Kumar BS
Mar 3 at 15:59
The output I have in this case isindex: 5 name: <module-cli-protocol-unix> argument: <> index: 6 name: <module-switch-on-port-available> argument: <> index: 7 name: <module-udev-detect> argument: <> index: 8 name: <module-bluetooth-policy> argument: <> index: 9 name: <module-bluetooth-discover> argument: <> index: 10 name: <module-cli-protocol-unix> argument: <sink_name=module-cli_>
– user390525
Mar 3 at 16:23
Thank you. It is very interesting; But it doesn't extract themodule-cli-protocol-unix
params only :P According to the input format I give in my question the output at lease must have one module cause there are only onemodule-cli-protocol-unix
module has non-empty argument but still the solution must be dynamic in case some new particular modules may be init-ed
– user390525
Mar 3 at 16:28
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
pacmd list-modules |
grep -B2 'argument: <[^>]' |
grep -B1 -A1 'name: <module-cli-protocol-unix>'
- The
-B
option prints lines before a match as well as the match itself - the
-A
option prints lines after a match - if whitespace is a problem, it can be stripped with sed, for example
So the process is:
- list all the modules
- filter on non-zero arguments
- then filter on the corect module name
Thank you for your reply. Is there a way to have-e 'index: '
which is related to the selected module? I just triedpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but seems like it outputs all existing modules index-es instead of the found one :P
– user390525
Feb 25 at 4:02
read the grep documentation on the meaning of-B
and-v
– jhnc
Feb 25 at 4:06
2
pacmd list-modules | grep -B2 'argument: <[^>]' | grep -B1 name: <module-cli-protocol-unix>'
– jhnc
Feb 25 at 4:09
I just edited my question please see it.
– user390525
Feb 25 at 4:20
See my amended comment
– jhnc
Feb 25 at 4:26
|
show 1 more comment
pacmd list-modules |
grep -B2 'argument: <[^>]' |
grep -B1 -A1 'name: <module-cli-protocol-unix>'
- The
-B
option prints lines before a match as well as the match itself - the
-A
option prints lines after a match - if whitespace is a problem, it can be stripped with sed, for example
So the process is:
- list all the modules
- filter on non-zero arguments
- then filter on the corect module name
Thank you for your reply. Is there a way to have-e 'index: '
which is related to the selected module? I just triedpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but seems like it outputs all existing modules index-es instead of the found one :P
– user390525
Feb 25 at 4:02
read the grep documentation on the meaning of-B
and-v
– jhnc
Feb 25 at 4:06
2
pacmd list-modules | grep -B2 'argument: <[^>]' | grep -B1 name: <module-cli-protocol-unix>'
– jhnc
Feb 25 at 4:09
I just edited my question please see it.
– user390525
Feb 25 at 4:20
See my amended comment
– jhnc
Feb 25 at 4:26
|
show 1 more comment
pacmd list-modules |
grep -B2 'argument: <[^>]' |
grep -B1 -A1 'name: <module-cli-protocol-unix>'
- The
-B
option prints lines before a match as well as the match itself - the
-A
option prints lines after a match - if whitespace is a problem, it can be stripped with sed, for example
So the process is:
- list all the modules
- filter on non-zero arguments
- then filter on the corect module name
pacmd list-modules |
grep -B2 'argument: <[^>]' |
grep -B1 -A1 'name: <module-cli-protocol-unix>'
- The
-B
option prints lines before a match as well as the match itself - the
-A
option prints lines after a match - if whitespace is a problem, it can be stripped with sed, for example
So the process is:
- list all the modules
- filter on non-zero arguments
- then filter on the corect module name
edited Mar 3 at 22:06
answered Feb 24 at 7:27
jhncjhnc
1514
1514
Thank you for your reply. Is there a way to have-e 'index: '
which is related to the selected module? I just triedpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but seems like it outputs all existing modules index-es instead of the found one :P
– user390525
Feb 25 at 4:02
read the grep documentation on the meaning of-B
and-v
– jhnc
Feb 25 at 4:06
2
pacmd list-modules | grep -B2 'argument: <[^>]' | grep -B1 name: <module-cli-protocol-unix>'
– jhnc
Feb 25 at 4:09
I just edited my question please see it.
– user390525
Feb 25 at 4:20
See my amended comment
– jhnc
Feb 25 at 4:26
|
show 1 more comment
Thank you for your reply. Is there a way to have-e 'index: '
which is related to the selected module? I just triedpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but seems like it outputs all existing modules index-es instead of the found one :P
– user390525
Feb 25 at 4:02
read the grep documentation on the meaning of-B
and-v
– jhnc
Feb 25 at 4:06
2
pacmd list-modules | grep -B2 'argument: <[^>]' | grep -B1 name: <module-cli-protocol-unix>'
– jhnc
Feb 25 at 4:09
I just edited my question please see it.
– user390525
Feb 25 at 4:20
See my amended comment
– jhnc
Feb 25 at 4:26
Thank you for your reply. Is there a way to have
-e 'index: '
which is related to the selected module? I just tried pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but seems like it outputs all existing modules index-es instead of the found one :P– user390525
Feb 25 at 4:02
Thank you for your reply. Is there a way to have
-e 'index: '
which is related to the selected module? I just tried pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but seems like it outputs all existing modules index-es instead of the found one :P– user390525
Feb 25 at 4:02
read the grep documentation on the meaning of
-B
and -v
– jhnc
Feb 25 at 4:06
read the grep documentation on the meaning of
-B
and -v
– jhnc
Feb 25 at 4:06
2
2
pacmd list-modules | grep -B2 'argument: <[^>]' | grep -B1 name: <module-cli-protocol-unix>'
– jhnc
Feb 25 at 4:09
pacmd list-modules | grep -B2 'argument: <[^>]' | grep -B1 name: <module-cli-protocol-unix>'
– jhnc
Feb 25 at 4:09
I just edited my question please see it.
– user390525
Feb 25 at 4:20
I just edited my question please see it.
– user390525
Feb 25 at 4:20
See my amended comment
– jhnc
Feb 25 at 4:26
See my amended comment
– jhnc
Feb 25 at 4:26
|
show 1 more comment
It will be unclear until you provide some sample, but you can try:
pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>'
It will first reject all strings having empty values for argument and then will only grep those lines which have name: <module-cli-protocol-unix>
.
Thank you. Seems like it is very nearby the point. I also tried to include index with the expressionpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but it outputs all modules index-es not the found ones :(
– user390525
Feb 25 at 4:13
@user390525 you can use one more pipe and then usegrep -e 'index: '
.
– Prvt_Yadv
Feb 25 at 8:46
add a comment |
It will be unclear until you provide some sample, but you can try:
pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>'
It will first reject all strings having empty values for argument and then will only grep those lines which have name: <module-cli-protocol-unix>
.
Thank you. Seems like it is very nearby the point. I also tried to include index with the expressionpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but it outputs all modules index-es not the found ones :(
– user390525
Feb 25 at 4:13
@user390525 you can use one more pipe and then usegrep -e 'index: '
.
– Prvt_Yadv
Feb 25 at 8:46
add a comment |
It will be unclear until you provide some sample, but you can try:
pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>'
It will first reject all strings having empty values for argument and then will only grep those lines which have name: <module-cli-protocol-unix>
.
It will be unclear until you provide some sample, but you can try:
pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>'
It will first reject all strings having empty values for argument and then will only grep those lines which have name: <module-cli-protocol-unix>
.
answered Feb 24 at 8:00
Prvt_YadvPrvt_Yadv
2,66231027
2,66231027
Thank you. Seems like it is very nearby the point. I also tried to include index with the expressionpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but it outputs all modules index-es not the found ones :(
– user390525
Feb 25 at 4:13
@user390525 you can use one more pipe and then usegrep -e 'index: '
.
– Prvt_Yadv
Feb 25 at 8:46
add a comment |
Thank you. Seems like it is very nearby the point. I also tried to include index with the expressionpacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but it outputs all modules index-es not the found ones :(
– user390525
Feb 25 at 4:13
@user390525 you can use one more pipe and then usegrep -e 'index: '
.
– Prvt_Yadv
Feb 25 at 8:46
Thank you. Seems like it is very nearby the point. I also tried to include index with the expression
pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but it outputs all modules index-es not the found ones :(– user390525
Feb 25 at 4:13
Thank you. Seems like it is very nearby the point. I also tried to include index with the expression
pacmd list-modules | grep -v 'argument: <>' | grep -e 'name: <module-cli-protocol-unix>' -e 'index: '
but it outputs all modules index-es not the found ones :(– user390525
Feb 25 at 4:13
@user390525 you can use one more pipe and then use
grep -e 'index: '
.– Prvt_Yadv
Feb 25 at 8:46
@user390525 you can use one more pipe and then use
grep -e 'index: '
.– Prvt_Yadv
Feb 25 at 8:46
add a comment |
If you are considering argument: <>
to be an empty argument then this could work
pacmd list-modules | grep -B2 '^argument: <..*>' | grep -E '^(index|name|argument):'
Output from sample:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
what grep version do you use? I have v3.0 now installed.
– user390525
Mar 3 at 16:00
No, I want the argument to be NOT EMPTY; I mean it should have values like aargument: <some_param=value etc>
– user390525
Mar 3 at 16:03
SO GIVE SOME EXAMPLES SO WE DONT HAVE TO KEEP GUESSING
– roaima
Mar 3 at 16:53
OK. I edited my question adding comments to the exact input source the module(s) which is about to be extracted; But the final solution should be dynamic in case a similar module is about to be init-ed...
– user390525
Mar 3 at 17:24
add a comment |
If you are considering argument: <>
to be an empty argument then this could work
pacmd list-modules | grep -B2 '^argument: <..*>' | grep -E '^(index|name|argument):'
Output from sample:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
what grep version do you use? I have v3.0 now installed.
– user390525
Mar 3 at 16:00
No, I want the argument to be NOT EMPTY; I mean it should have values like aargument: <some_param=value etc>
– user390525
Mar 3 at 16:03
SO GIVE SOME EXAMPLES SO WE DONT HAVE TO KEEP GUESSING
– roaima
Mar 3 at 16:53
OK. I edited my question adding comments to the exact input source the module(s) which is about to be extracted; But the final solution should be dynamic in case a similar module is about to be init-ed...
– user390525
Mar 3 at 17:24
add a comment |
If you are considering argument: <>
to be an empty argument then this could work
pacmd list-modules | grep -B2 '^argument: <..*>' | grep -E '^(index|name|argument):'
Output from sample:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
If you are considering argument: <>
to be an empty argument then this could work
pacmd list-modules | grep -B2 '^argument: <..*>' | grep -E '^(index|name|argument):'
Output from sample:
index: 9
name: <module-cli-protocol-unix>
argument: <sink_name=module-cli_>
answered Mar 2 at 16:48
roaimaroaima
45.6k757124
45.6k757124
what grep version do you use? I have v3.0 now installed.
– user390525
Mar 3 at 16:00
No, I want the argument to be NOT EMPTY; I mean it should have values like aargument: <some_param=value etc>
– user390525
Mar 3 at 16:03
SO GIVE SOME EXAMPLES SO WE DONT HAVE TO KEEP GUESSING
– roaima
Mar 3 at 16:53
OK. I edited my question adding comments to the exact input source the module(s) which is about to be extracted; But the final solution should be dynamic in case a similar module is about to be init-ed...
– user390525
Mar 3 at 17:24
add a comment |
what grep version do you use? I have v3.0 now installed.
– user390525
Mar 3 at 16:00
No, I want the argument to be NOT EMPTY; I mean it should have values like aargument: <some_param=value etc>
– user390525
Mar 3 at 16:03
SO GIVE SOME EXAMPLES SO WE DONT HAVE TO KEEP GUESSING
– roaima
Mar 3 at 16:53
OK. I edited my question adding comments to the exact input source the module(s) which is about to be extracted; But the final solution should be dynamic in case a similar module is about to be init-ed...
– user390525
Mar 3 at 17:24
what grep version do you use? I have v3.0 now installed.
– user390525
Mar 3 at 16:00
what grep version do you use? I have v3.0 now installed.
– user390525
Mar 3 at 16:00
No, I want the argument to be NOT EMPTY; I mean it should have values like a
argument: <some_param=value etc>
– user390525
Mar 3 at 16:03
No, I want the argument to be NOT EMPTY; I mean it should have values like a
argument: <some_param=value etc>
– user390525
Mar 3 at 16:03
SO GIVE SOME EXAMPLES SO WE DONT HAVE TO KEEP GUESSING
– roaima
Mar 3 at 16:53
SO GIVE SOME EXAMPLES SO WE DONT HAVE TO KEEP GUESSING
– roaima
Mar 3 at 16:53
OK. I edited my question adding comments to the exact input source the module(s) which is about to be extracted; But the final solution should be dynamic in case a similar module is about to be init-ed...
– user390525
Mar 3 at 17:24
OK. I edited my question adding comments to the exact input source the module(s) which is about to be extracted; But the final solution should be dynamic in case a similar module is about to be init-ed...
– user390525
Mar 3 at 17:24
add a comment |
Tried with below command and worked fine
command
pacmd list-modules|awk '/index: [0-9]/||/name: <.*>/||/argument: <.*?>/{print $0}'
Thank you for your reply. I am not sure how to integrate the solution if to use the$pacmd list-modules
utility command instead of the filename?
– user390525
Mar 2 at 18:35
I am not sure how to convert it to grep? Could you provide the solution with grep util?
– user390525
Mar 3 at 15:58
KIndly check edited posted
– Praveen Kumar BS
Mar 3 at 15:59
The output I have in this case isindex: 5 name: <module-cli-protocol-unix> argument: <> index: 6 name: <module-switch-on-port-available> argument: <> index: 7 name: <module-udev-detect> argument: <> index: 8 name: <module-bluetooth-policy> argument: <> index: 9 name: <module-bluetooth-discover> argument: <> index: 10 name: <module-cli-protocol-unix> argument: <sink_name=module-cli_>
– user390525
Mar 3 at 16:23
Thank you. It is very interesting; But it doesn't extract themodule-cli-protocol-unix
params only :P According to the input format I give in my question the output at lease must have one module cause there are only onemodule-cli-protocol-unix
module has non-empty argument but still the solution must be dynamic in case some new particular modules may be init-ed
– user390525
Mar 3 at 16:28
add a comment |
Tried with below command and worked fine
command
pacmd list-modules|awk '/index: [0-9]/||/name: <.*>/||/argument: <.*?>/{print $0}'
Thank you for your reply. I am not sure how to integrate the solution if to use the$pacmd list-modules
utility command instead of the filename?
– user390525
Mar 2 at 18:35
I am not sure how to convert it to grep? Could you provide the solution with grep util?
– user390525
Mar 3 at 15:58
KIndly check edited posted
– Praveen Kumar BS
Mar 3 at 15:59
The output I have in this case isindex: 5 name: <module-cli-protocol-unix> argument: <> index: 6 name: <module-switch-on-port-available> argument: <> index: 7 name: <module-udev-detect> argument: <> index: 8 name: <module-bluetooth-policy> argument: <> index: 9 name: <module-bluetooth-discover> argument: <> index: 10 name: <module-cli-protocol-unix> argument: <sink_name=module-cli_>
– user390525
Mar 3 at 16:23
Thank you. It is very interesting; But it doesn't extract themodule-cli-protocol-unix
params only :P According to the input format I give in my question the output at lease must have one module cause there are only onemodule-cli-protocol-unix
module has non-empty argument but still the solution must be dynamic in case some new particular modules may be init-ed
– user390525
Mar 3 at 16:28
add a comment |
Tried with below command and worked fine
command
pacmd list-modules|awk '/index: [0-9]/||/name: <.*>/||/argument: <.*?>/{print $0}'
Tried with below command and worked fine
command
pacmd list-modules|awk '/index: [0-9]/||/name: <.*>/||/argument: <.*?>/{print $0}'
edited Mar 3 at 15:59
answered Mar 2 at 18:20
Praveen Kumar BSPraveen Kumar BS
1,5461311
1,5461311
Thank you for your reply. I am not sure how to integrate the solution if to use the$pacmd list-modules
utility command instead of the filename?
– user390525
Mar 2 at 18:35
I am not sure how to convert it to grep? Could you provide the solution with grep util?
– user390525
Mar 3 at 15:58
KIndly check edited posted
– Praveen Kumar BS
Mar 3 at 15:59
The output I have in this case isindex: 5 name: <module-cli-protocol-unix> argument: <> index: 6 name: <module-switch-on-port-available> argument: <> index: 7 name: <module-udev-detect> argument: <> index: 8 name: <module-bluetooth-policy> argument: <> index: 9 name: <module-bluetooth-discover> argument: <> index: 10 name: <module-cli-protocol-unix> argument: <sink_name=module-cli_>
– user390525
Mar 3 at 16:23
Thank you. It is very interesting; But it doesn't extract themodule-cli-protocol-unix
params only :P According to the input format I give in my question the output at lease must have one module cause there are only onemodule-cli-protocol-unix
module has non-empty argument but still the solution must be dynamic in case some new particular modules may be init-ed
– user390525
Mar 3 at 16:28
add a comment |
Thank you for your reply. I am not sure how to integrate the solution if to use the$pacmd list-modules
utility command instead of the filename?
– user390525
Mar 2 at 18:35
I am not sure how to convert it to grep? Could you provide the solution with grep util?
– user390525
Mar 3 at 15:58
KIndly check edited posted
– Praveen Kumar BS
Mar 3 at 15:59
The output I have in this case isindex: 5 name: <module-cli-protocol-unix> argument: <> index: 6 name: <module-switch-on-port-available> argument: <> index: 7 name: <module-udev-detect> argument: <> index: 8 name: <module-bluetooth-policy> argument: <> index: 9 name: <module-bluetooth-discover> argument: <> index: 10 name: <module-cli-protocol-unix> argument: <sink_name=module-cli_>
– user390525
Mar 3 at 16:23
Thank you. It is very interesting; But it doesn't extract themodule-cli-protocol-unix
params only :P According to the input format I give in my question the output at lease must have one module cause there are only onemodule-cli-protocol-unix
module has non-empty argument but still the solution must be dynamic in case some new particular modules may be init-ed
– user390525
Mar 3 at 16:28
Thank you for your reply. I am not sure how to integrate the solution if to use the
$pacmd list-modules
utility command instead of the filename?– user390525
Mar 2 at 18:35
Thank you for your reply. I am not sure how to integrate the solution if to use the
$pacmd list-modules
utility command instead of the filename?– user390525
Mar 2 at 18:35
I am not sure how to convert it to grep? Could you provide the solution with grep util?
– user390525
Mar 3 at 15:58
I am not sure how to convert it to grep? Could you provide the solution with grep util?
– user390525
Mar 3 at 15:58
KIndly check edited posted
– Praveen Kumar BS
Mar 3 at 15:59
KIndly check edited posted
– Praveen Kumar BS
Mar 3 at 15:59
The output I have in this case is
index: 5 name: <module-cli-protocol-unix> argument: <> index: 6 name: <module-switch-on-port-available> argument: <> index: 7 name: <module-udev-detect> argument: <> index: 8 name: <module-bluetooth-policy> argument: <> index: 9 name: <module-bluetooth-discover> argument: <> index: 10 name: <module-cli-protocol-unix> argument: <sink_name=module-cli_>
– user390525
Mar 3 at 16:23
The output I have in this case is
index: 5 name: <module-cli-protocol-unix> argument: <> index: 6 name: <module-switch-on-port-available> argument: <> index: 7 name: <module-udev-detect> argument: <> index: 8 name: <module-bluetooth-policy> argument: <> index: 9 name: <module-bluetooth-discover> argument: <> index: 10 name: <module-cli-protocol-unix> argument: <sink_name=module-cli_>
– user390525
Mar 3 at 16:23
Thank you. It is very interesting; But it doesn't extract the
module-cli-protocol-unix
params only :P According to the input format I give in my question the output at lease must have one module cause there are only one module-cli-protocol-unix
module has non-empty argument but still the solution must be dynamic in case some new particular modules may be init-ed– user390525
Mar 3 at 16:28
Thank you. It is very interesting; But it doesn't extract the
module-cli-protocol-unix
params only :P According to the input format I give in my question the output at lease must have one module cause there are only one module-cli-protocol-unix
module has non-empty argument but still the solution must be dynamic in case some new particular modules may be init-ed– user390525
Mar 3 at 16:28
add a comment |
7
Please provide an example of source data, so we can try out your commands against a known input.
– roaima
Feb 23 at 0:20
@roaima you mean the result output? The full output is the pulseaudio's
$pacmd list-modules
– user390525
Feb 23 at 0:28
This is conjecture at best, but I suspect you are after
$pacmd list-modules | grep -e 'name: <module-cli-protocol-unix>' | grep -e 'argument:
– iruvar
Feb 23 at 3:53
@iruvar in this case the argument also outputs as
argument: <>
if it is empty so how to skip if there isargument: <>
also output expected?– user390525
Feb 24 at 2:48
@user390525 To be able to test solutions to this issue, we would need to know what the input to
grep
might look like, and we also (for clarity) need to know what you expect to get as the result under different conditions. I have voted to close this question as "unclear" until such information is added.– Kusalananda
Feb 24 at 10:26