LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2013, 12:44 AM   #1
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Rep: Reputation: 1
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.
 
Old 12-09-2013, 01:48 AM   #2
mddnix
Member
 
Registered: Mar 2013
Location: Bangalore, India
Distribution: Redhat, Arch, Ubuntu
Posts: 512

Rep: Reputation: 139Reputation: 139
Code:
grep '^backup_id\|^creation\|^expiration\|^policy\|^sched_label'
 
3 members found this post helpful.
Old 12-09-2013, 01:54 AM   #3
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
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.
 
Old 12-09-2013, 09:54 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,952

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by manalisharmabe View Post
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.
 
Old 12-17-2013, 05:01 AM   #5
manalisharmabe
Member
 
Registered: Dec 2010
Posts: 242

Original Poster
Rep: Reputation: 1
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i need to output a text file in proper format anurupr Linux - Newbie 2 03-04-2010 04:14 AM
[SOLVED] F11: proper format for fstab line duplicating desired mount command mejohnsn Fedora 7 10-10-2009 08:41 AM
Question about proper video format to burn to dvd Rick069 Linux - Software 1 11-11-2005 03:50 AM
perl print double in proper format rajatgarg Programming 1 01-30-2004 01:57 PM
Linux - ASCI - Windows, proper file format issue aaronluke Linux - General 1 11-07-2002 11:47 PM


All times are GMT -5. The time now is 05:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration