LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to grep this Data in proper format:- Please Guide (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-grep-this-data-in-proper-format-please-guide-4175487340/)

manalisharmabe 12-08-2013 11:44 PM

Need to grep this Data in proper format:- Please Guide
 
Hi Guys,

I need to grep below data in this format
backup_id
creation
expiration
policy
sched_label

Code:

backup_id = picoserver38_1212077050, version = 2
creation = 05/29/2008 18:04:10 (1212077050)
expiration = 06/29/2008 18:04:10 (1214755450)
retention_level = 3, fragment = 2, file_num = 1
block_size = 262144, status = 0x0
media_id = ADC020, size = 0, data_start = 2
client_type = 13, copy_num = 1
sched_type = 0, flags = 0x0
policy = picoserver38_san
sched_label = picoserver38_full_daily
opt_extra = 0, mpx_headers = 1, res1 = 0

backup_id = picoserver38_1212076929, version = 2
creation = 05/29/2008 18:02:09 (1212076929)
expiration = 06/29/2008 18:02:09 (1214755329)
retention_level = 3, fragment = 3, file_num = 2
block_size = 262144, status = 0x0
media_id = ADC020, size = 0, data_start = 108410
client_type = 13, copy_num = 1
sched_type = 0, flags = 0x0
policy = picoserver38_san
sched_label = picoserver38_full_daily
opt_extra = 0, mpx_headers = 2, res1 = 0

I could grep only this, media_id did not come here.
Code:

-bash-3.00$  sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC020 -L | grep creation | grep -v 'media_id'
creation = 05/29/2008 18:02:09 (1212076929)
creation = 05/29/2008 18:04:09 (1212077049)
creation = 05/29/2008 18:04:10 (1212077050)
creation = 05/29/2008 18:02:09 (1212076929)
creation = 05/29/2008 18:04:09 (1212077049)

Please Advise.

Thanks.

Madhu Desai 12-09-2013 12:48 AM

Code:

grep '^backup_id\|^creation\|^expiration\|^policy\|^sched_label'

manalisharmabe 12-09-2013 12:54 AM

OS is Solaris 10

I used this one

Code:


-bash-3.00$ sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC020 -L | /usr/sfw/bin/ggrep -E "^backup_id|^creation|^expiration|^policy|^sched_label" | awk '{print "creation",$2,$3,$4,$5}'

Password:

creation = N.A (0)

creation = picoserver38_1212076929, version =

creation = 05/29/2008 18:02:09 (1212076929)

creation = 06/29/2008 18:02:09 (1214755329)

creation = picoserver38_san

creation = picoserver38_full_daily

creation = picoserver38_1212077049, version =

creation = 05/29/2008 18:04:09 (1212077049)

creation = 06/29/2008 18:04:09 (1214755449)

creation = picoserver38_san

creation = picoserver38_full_daily

creation = picoserver38_1212077050, version =

creation = 05/29/2008 18:04:10 (1212077050)

creation = 06/29/2008 18:04:10 (1214755450)

creation = picoserver38_san

creation = picoserver38_full_daily

creation = picoserver38_1212076929, version =

creation = 05/29/2008 18:02:09 (1212076929)

creation = 06/29/2008 18:02:09 (1214755329)

creation = picoserver38_san

creation = picoserver38_full_daily

creation = picoserver38_1212077049, version =

creation = 05/29/2008 18:04:09 (1212077049)

creation = 06/29/2008 18:04:09 (1214755449)

creation = picoserver38_san

creation = picoserver38_full_daily

-bash-3.00$



Can I have something like this in column



Media_id |backup_id | Policy | sched_label | creation | expiration |



I mean from one paragraph into one row, below are the two paragraphs.



Code:


backup_id = picoserver38_1212076929, version = 2

creation = 05/29/2008 18:02:09 (1212076929)

expiration = 06/29/2008 18:02:09 (1214755329)

retention_level = 3, fragment = 3, file_num = 2

block_size = 262144, status = 0x0

media_id = ADC020, size = 0, data_start = 108410

client_type = 13, copy_num = 1

sched_type = 0, flags = 0x0

policy = picoserver38_san

sched_label = picoserver38_full_daily

opt_extra = 0, mpx_headers = 2, res1 = 0

 

backup_id = picoserver38_1212077049, version = 2

creation = 05/29/2008 18:04:09 (1212077049)

expiration = 06/29/2008 18:04:09 (1214755449)

retention_level = 3, fragment = 3, file_num = 2

block_size = 262144, status = 0x0

media_id = ADC020, size = 0, data_start = 108410

client_type = 13, copy_num = 1

sched_type = 0, flags = 0x0

policy = picoserver38_san

sched_label = picoserver38_full_daily

opt_extra = 0, mpx_headers = 1, res1 = 0



Thanks for you help till now.



Please advise.






I need below info only , its ok if I dont get media_id as I am running command with media_id only.



Code:


-bash-3.00$ sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC020 -L | /usr/sfw/bin/ggrep -E "^media_id|^backup_id|^creation|^expiration|^policy|^sched_label"

Password:

media_id = ADC020, partner_id = *NULL*, version = 1

expiration = N.A (0)

backup_id = picoserver38_1212076929, version = 2

creation = 05/29/2008 18:02:09 (1212076929)

expiration = 06/29/2008 18:02:09 (1214755329)

media_id = ADC020, size = 0, data_start = 2

policy = picoserver38_san

sched_label = picoserver38_full_daily

backup_id = picoserver38_1212077049, version = 2

creation = 05/29/2008 18:04:09 (1212077049)

expiration = 06/29/2008 18:04:09 (1214755449)

media_id = ADC020, size = 0, data_start = 2

policy = picoserver38_san

sched_label = picoserver38_full_daily

backup_id = picoserver38_1212077050, version = 2

creation = 05/29/2008 18:04:10 (1212077050)

expiration = 06/29/2008 18:04:10 (1214755450)

media_id = ADC020, size = 0, data_start = 2

policy = picoserver38_san

sched_label = picoserver38_full_daily

backup_id = picoserver38_1212076929, version = 2

creation = 05/29/2008 18:02:09 (1212076929)

expiration = 06/29/2008 18:02:09 (1214755329)

media_id = ADC020, size = 0, data_start = 108410

policy = picoserver38_san

sched_label = picoserver38_full_daily

backup_id = picoserver38_1212077049, version = 2

creation = 05/29/2008 18:04:09 (1212077049)

expiration = 06/29/2008 18:04:09 (1214755449)

media_id = ADC020, size = 0, data_start = 108410

policy = picoserver38_san

sched_label = picoserver38_full_daily

-bash-3.00$



Above bold info is what I need.



Thanks.

TB0ne 12-09-2013 08:54 AM

Quote:

Originally Posted by manalisharmabe (Post 5077726)
OS is Solaris 10
I used this one
Code:

-bash-3.00$ sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC020 -L | /usr/sfw/bin/ggrep -E "^backup_id|^creation|^expiration|^policy|^sched_label" | awk '{print "creation",$2,$3,$4,$5}'
Can I have something like this in column

Media_id |backup_id | Policy | sched_label | creation | expiration |

I mean from one paragraph into one row, below are the two paragraphs.
Code:

backup_id = picoserver38_1212076929, version = 2
creation = 05/29/2008 18:02:09 (1212076929)
expiration = 06/29/2008 18:02:09 (1214755329)
retention_level = 3, fragment = 3, file_num = 2
block_size = 262144, status = 0x0
media_id = ADC020, size = 0, data_start = 108410
client_type = 13, copy_num = 1
sched_type = 0, flags = 0x0
policy = picoserver38_san
sched_label = picoserver38_full_daily
opt_extra = 0, mpx_headers = 2, res1 = 0
backup_id = picoserver38_1212077049, version = 2
creation = 05/29/2008 18:04:09 (1212077049)
expiration = 06/29/2008 18:04:09 (1214755449)
retention_level = 3, fragment = 3, file_num = 2
block_size = 262144, status = 0x0
media_id = ADC020, size = 0, data_start = 108410
client_type = 13, copy_num = 1
sched_type = 0, flags = 0x0
policy = picoserver38_san
sched_label = picoserver38_full_daily
opt_extra = 0, mpx_headers = 1, res1 = 0

Thanks for you help till now. Please advise.

I need below info only , its ok if I dont get media_id as I am running command with media_id only.
Code:

-bash-3.00$ sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC020 -L | /usr/sfw/bin/ggrep -E "^media_id|^backup_id|^creation|^expiration|^policy|^sched_label"

media_id = ADC020, partner_id = *NULL*, version = 1
expiration = N.A (0)
backup_id = picoserver38_1212076929, version = 2
creation = 05/29/2008 18:02:09 (1212076929)
expiration = 06/29/2008 18:02:09 (1214755329)
media_id = ADC020, size = 0, data_start = 2
policy = picoserver38_san
sched_label = picoserver38_full_daily
backup_id = picoserver38_1212077049, version = 2
creation = 05/29/2008 18:04:09 (1212077049)
expiration = 06/29/2008 18:04:09 (1214755449)
media_id = ADC020, size = 0, data_start = 2
policy = picoserver38_san
sched_label = picoserver38_full_daily
backup_id = picoserver38_1212077050, version = 2
creation = 05/29/2008 18:04:10 (1212077050)
expiration = 06/29/2008 18:04:10 (1214755450)
media_id = ADC020, size = 0, data_start = 2
policy = picoserver38_san
sched_label = picoserver38_full_daily
backup_id = picoserver38_1212076929, version = 2
creation = 05/29/2008 18:02:09 (1212076929)
expiration = 06/29/2008 18:02:09 (1214755329)
media_id = ADC020, size = 0, data_start = 108410
policy = picoserver38_san
sched_label = picoserver38_full_daily
backup_id = picoserver38_1212077049, version = 2
creation = 05/29/2008 18:04:09 (1212077049)
expiration = 06/29/2008 18:04:09 (1214755449)
media_id = ADC020, size = 0, data_start = 108410
policy = picoserver38_san
sched_label = picoserver38_full_daily

Above bold info is what I need.

You didn't put anything in bold, so we don't know exactly what you're after...your posts are fairly unclear. And can you show us what YOU have done/tried so far??? You've asked several scripting questions in the past, has none of that information helped you here?

If you're looking to join lines together or get them in a CSV format, you can do it with either sed or awk, and there are MANY examples on how to do that you can find on LQ (the search function can show you), and Google has them as well.

manalisharmabe 12-17-2013 04:01 AM

I Thank to you all.

Problem is solved.

I used below stuff to get required Info.


Code:

-bash-3.00$  sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC806 -L | /usr/sfw/bin/ggrep -E "^media_id|^backup_id|^creation|^expiration|^policy|^sched_label" > ~user11/zFINALTAPES/SADC806.txt

-bash-3.00$ cat ~user11/zFINALTAPES/SADC793.txt | grep  sched_label

.

Thanks.


All times are GMT -5. The time now is 04:39 PM.