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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to grep this Data in proper format:- Please Guide
# 8  
Old 12-09-2013
Could you please provide desire output ?
This User Gave Thanks to pravin27 For This Post:
# 9  
Old 12-09-2013
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.

---------- Post updated at 12:13 PM ---------- Previous update was at 12:01 PM ----------

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.

---------- Post updated at 02:17 PM ---------- Previous update was at 12:13 PM ----------

Hey please answer me,

How can I use below command with awk for expiration and policy and sched_label

Code:
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}'

Please guide

I mean do I have use something like this :-
Code:
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","policy",$2,$3,$4,$5}'

# 10  
Old 12-09-2013
Code:
sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC020 -L | awk -F"=" '/^backup_id/{$1="";backup_id[++i]=$0}
/^creation/{$1="";creation[i]=$0}
/^expiration/{$1="";expiration[i]=$0}
/^media_id/{$1="";media_id[i]=$0}
/^policy/{$1="";policy[i]=$0}
/^sched_label/{$1="";sched_label[i]=$0}
END { print "Media_id |backup_id | Policy | sched_label | creation | expiration";for(j=1;j<=i;j++) {
print media_id[j]"|"backup_id[j]"|"policy[j]"|"sched_label[j]"|"creation[j]"|"expiration[j]
}}'

This User Gave Thanks to pravin27 For This Post:
# 11  
Old 12-09-2013
Quote:
Originally Posted by pravin27
Code:
sudo /usr/openv/netbackup/bin/admincmd/bpmedialist -mcontents -m ADC020 -L | awk -F"=" '/^backup_id/{$1="";backup_id[++i]=$0}
/^creation/{$1="";creation[i]=$0}
/^expiration/{$1="";expiration[i]=$0}
/^media_id/{$1="";media_id[i]=$0}
/^policy/{$1="";policy[i]=$0}
/^sched_label/{$1="";sched_label[i]=$0}
END { print "Media_id |backup_id | Policy | sched_label | creation | expiration";for(j=1;j<=i;j++) {
print media_id[j]"|"backup_id[j]"|"policy[j]"|"sched_label[j]"|"creation[j]"|"expiration[j]
}}'

Wow! Looks fine.

You mean to say I need to create a script for this?
But I need to yun this for almost 100 Tape numbers ADC001 too ADC100.
My machine is production machine.Smilie The backup ServerSmilie

However I have one tiny query, i searched google a lot but did not get answer,
how to grep word only once without repeating

Code:
-bash-3.00$ cat /zFINAL142TAPES/ADC094.txt  | grep policy  intel_class_i
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = ams_linux_prod1
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win7
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win2008_2
policy = intel_class_win200

Please advise

---------- Post updated at 05:00 PM ---------- Previous update was at 04:34 PM ----------

Hey Hi Pravin,

Can I directly copy paste and run the above given code on command line to get desired output or do I need to create script for that?

Please advise.
# 12  
Old 12-09-2013
Quote:
Originally Posted by manalisharmabe
...
However I have one tiny query, i searched google a lot but did not get answer,
how to grep word only once without repeating ...
Do you mean quit after the first match? Try grep -m1
Do you mean one line per repeating patterns? Pipe result through sort -u
Don't you want to lose the original sort order? Pipe through awk '!T[$0]++'
This User Gave Thanks to RudiC For This Post:
# 13  
Old 12-10-2013
Hey I came to know, it is really simple, use uniq. ans for my that tiny question :-)
# 14  
Old 12-10-2013
uniq will work on sorted (or at least entire "paragraphs" with duplicates) files only.
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Combine multiline to one line with proper format

Hello Guys, I have a file say FILE1.txt contains below data:- A B C D E F G H I J K L I need the output in another file as FILE2 as:- 'A', 'B', 'C', 'D', 'E', (7 Replies)
Discussion started by: jassi10781
7 Replies

2. Shell Programming and Scripting

Awk - Summation in Proper decimal Format

Hi I am executing below command to do summation on 46th coloumn. cat File1| awk -F"|" '{p += $46} END { printf"Column Name | SUM | " p}' I am getting output as Column Name | SUM | 1.01139e+10 Here I want output in Proper decimal format. Can someone tell me what change is required for same? (1 Reply)
Discussion started by: sanranad
1 Replies

3. Shell Programming and Scripting

Need to split a xml file in proper format

Hi, I have a file which has xml data but all in single line Ex - <?xml version="1.0"?><User><Name>Robert</Name><Location>California</Location><Occupation>Programmer</Occupation></User> I want to split the data in proper xml format Ex- <?xml version="1.0"?> <User> <Name>Robert</Name>... (6 Replies)
Discussion started by: avishek007
6 Replies

4. Shell Programming and Scripting

Getting Proper Date Format in SH Script

There's a small SH script I'm trying to write where it will get the current month and find a log file that is based on the date. Example: Today is February, so the log file is going to be 201102.log (2011 + 02) An additional thing is that if today is the 1st of a month, it will also find the log... (3 Replies)
Discussion started by: kooshi
3 Replies

5. Shell Programming and Scripting

Output file not displayed in the proper format

Hi am using uuencode fro attaching one report which is nothing but sql query output. But when i receive the report through attachement and when it is opened the report is not displayed in proper format. Means if the sql query has 100 rows the mail attachment report displays the report in 2... (2 Replies)
Discussion started by: weknowd
2 Replies

6. Shell Programming and Scripting

Net::SSH::Perl ...... how to print the output in a proper format

Hi Guys, my $cmd = "ls -l"; #........ {or let it be as # my $cmd= "ls"; } my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("$cmd"); print $stdout; the script works fine, but i am unable to see the output getting displayed in a... (7 Replies)
Discussion started by: gsprasanna
7 Replies

7. BSD

proper syntax of grep command

I'm learning UNIX on my mac (BSD), using a manual. I'm trying to figure out the grep command, and am getting something wrong. I've opened one of my files in NeoOffice and am looking for a string, the phrase 'I am writing.' I've been to some sites to get the proper syntax, and from what I can see... (5 Replies)
Discussion started by: Straitsfan
5 Replies

8. Shell Programming and Scripting

Check for proper e mail id format

Hi, We run an application called meta which reads user information from database and updates in LDAP.For that we have some scripts to check the uniqueness of mail ids between the existing LDAP and Database.It works fine when people enter mail ids in proper format (xxx.yyy@abc.com) but if it... (2 Replies)
Discussion started by: prolay
2 Replies
Login or Register to Ask a Question