extract field from file using sed or awk

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have bash script to collect all hardware info but following memory info piece is missing, so this is what i am trying to do.
Following command give you status of DIMM memory module,
[root@Linux ~]# hpasmcli -s 'show dimm'
DIMM Configuration
------------------
Processor #: 1
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 1
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: DIMM is degraded
want to extract Size: and Status: and need that in single line, like following
Final output will look like following. I can use other language like python or perl but i wrote in bash so i need something in bash, i can do multiple for loop and play with variable to make it work but i need something easy or in-short single like like sed/awk. how can i achieve that in sed/awk?
8192MB - Ok
8192MB - OK
8192MB - OK
8192MB - DIMM is degraded
linux awk sed scripting regular-expression
add a comment |Â
up vote
0
down vote
favorite
I have bash script to collect all hardware info but following memory info piece is missing, so this is what i am trying to do.
Following command give you status of DIMM memory module,
[root@Linux ~]# hpasmcli -s 'show dimm'
DIMM Configuration
------------------
Processor #: 1
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 1
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: DIMM is degraded
want to extract Size: and Status: and need that in single line, like following
Final output will look like following. I can use other language like python or perl but i wrote in bash so i need something in bash, i can do multiple for loop and play with variable to make it work but i need something easy or in-short single like like sed/awk. how can i achieve that in sed/awk?
8192MB - Ok
8192MB - OK
8192MB - OK
8192MB - DIMM is degraded
linux awk sed scripting regular-expression
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have bash script to collect all hardware info but following memory info piece is missing, so this is what i am trying to do.
Following command give you status of DIMM memory module,
[root@Linux ~]# hpasmcli -s 'show dimm'
DIMM Configuration
------------------
Processor #: 1
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 1
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: DIMM is degraded
want to extract Size: and Status: and need that in single line, like following
Final output will look like following. I can use other language like python or perl but i wrote in bash so i need something in bash, i can do multiple for loop and play with variable to make it work but i need something easy or in-short single like like sed/awk. how can i achieve that in sed/awk?
8192MB - Ok
8192MB - OK
8192MB - OK
8192MB - DIMM is degraded
linux awk sed scripting regular-expression
I have bash script to collect all hardware info but following memory info piece is missing, so this is what i am trying to do.
Following command give you status of DIMM memory module,
[root@Linux ~]# hpasmcli -s 'show dimm'
DIMM Configuration
------------------
Processor #: 1
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 1
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 1
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: Ok
Processor #: 2
Module #: 12
Present: Yes
Form Factor: 9h
Memory Type: DDR3(18h)
Size: 8192 MB
Speed: 1333 MHz
Supports Lock Step: No
Configured for Lock Step: No
Status: DIMM is degraded
want to extract Size: and Status: and need that in single line, like following
Final output will look like following. I can use other language like python or perl but i wrote in bash so i need something in bash, i can do multiple for loop and play with variable to make it work but i need something easy or in-short single like like sed/awk. how can i achieve that in sed/awk?
8192MB - Ok
8192MB - OK
8192MB - OK
8192MB - DIMM is degraded
linux awk sed scripting regular-expression
linux awk sed scripting regular-expression
edited 4 mins ago
Jeff Schaller
34.4k951115
34.4k951115
asked 8 mins ago
Satish
61911130
61911130
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
Oh boy i think i did it :)
[root@Linux ~]# hpasmcli -s 'show dimm' | egrep -e Size -e Status | awk -F: 'print $2' | sed 's/^[ t]*//' | awk 'NR%2printf "%s - ",$0;next;1'
8192 MB - Ok
8192 MB - Ok
8192 MB - Ok
8192 MB - DIMM is degraded
Still i would like to know if anyother way we can do that, i am not going to answer my question i will wait for other folks to chime in.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Oh boy i think i did it :)
[root@Linux ~]# hpasmcli -s 'show dimm' | egrep -e Size -e Status | awk -F: 'print $2' | sed 's/^[ t]*//' | awk 'NR%2printf "%s - ",$0;next;1'
8192 MB - Ok
8192 MB - Ok
8192 MB - Ok
8192 MB - DIMM is degraded
Still i would like to know if anyother way we can do that, i am not going to answer my question i will wait for other folks to chime in.
add a comment |Â
up vote
0
down vote
Oh boy i think i did it :)
[root@Linux ~]# hpasmcli -s 'show dimm' | egrep -e Size -e Status | awk -F: 'print $2' | sed 's/^[ t]*//' | awk 'NR%2printf "%s - ",$0;next;1'
8192 MB - Ok
8192 MB - Ok
8192 MB - Ok
8192 MB - DIMM is degraded
Still i would like to know if anyother way we can do that, i am not going to answer my question i will wait for other folks to chime in.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Oh boy i think i did it :)
[root@Linux ~]# hpasmcli -s 'show dimm' | egrep -e Size -e Status | awk -F: 'print $2' | sed 's/^[ t]*//' | awk 'NR%2printf "%s - ",$0;next;1'
8192 MB - Ok
8192 MB - Ok
8192 MB - Ok
8192 MB - DIMM is degraded
Still i would like to know if anyother way we can do that, i am not going to answer my question i will wait for other folks to chime in.
Oh boy i think i did it :)
[root@Linux ~]# hpasmcli -s 'show dimm' | egrep -e Size -e Status | awk -F: 'print $2' | sed 's/^[ t]*//' | awk 'NR%2printf "%s - ",$0;next;1'
8192 MB - Ok
8192 MB - Ok
8192 MB - Ok
8192 MB - DIMM is degraded
Still i would like to know if anyother way we can do that, i am not going to answer my question i will wait for other folks to chime in.
answered 2 mins ago
Satish
61911130
61911130
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f477793%2fextract-field-from-file-using-sed-or-awk%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password