Results 1 to 10 of 10
I have an script that is taking an input of file and makes it look like:
Code:
* R###### Main 1.0.0.1 Active Some of the Backup Sets have not run ...
- 10-30-2007 #1Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
Repeating information from one line down until match is made on the next line
I have an script that is taking an input of file and makes it look like:
I am trying to make that R###### appear on everyline. Since there is multiple of these sections and the line count varies I was trying a sed script to do what I wanted. But it is not working.Code:* R###### Main 1.0.0.1 Active Some of the Backup Sets have not run since Oct 6, 2006 * Path\To\Backup A: Oct 20, 2007 Successful Path\To\Backup B: Oct 17, 2007 Successful Path\to\Backup C: Oct 19, 2007 Successful Path\to\Backup D: Oct 19, 2007 Successful * Path\To\Backup E: Oct 6, 2007 Successful R###### Main 1.0.0.1 Active Some of the Backup Sets have not run since Oct 25, 2006 * Path\To\Backup A: Oct 20, 2007 Successful Path\To\Backup B: Oct 17, 2007 Successful ...etc
Here is what I did
Output I want:Code:/^\R[0-9]*/,/^\R[0-9]*/{ s/^R[0-9]*/&/g }
Code:R00001 Main 1.0.0.1 Active Some of the Backup Sets have not run since Oct 6, 2006 R00001 Path\To\Backup A: R00001 Path\To\Backup B: R00001 Path\to\Backup C: R00001 Path\to\Backup D: R00001 Path\To\Backup E: R00003 Main 1.0.0.1 Active Some of the Backup Sets have not run since Oct 25, 2006 R00003 Path\To\Backup A: R00003 Path\To\Backup B:
Sadly that is not doing anything. I tried multiple other things. What am I doing wrong.
- 10-30-2007 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
i can't see how you get R00001 and R00003. anyway, its best also to give a sample of that input file
- 10-31-2007 #3Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
The R##### in the output file is an account number that is in the report allready. The first one is a sample of the excat file.
- 10-31-2007 #4If the input file is different than the one posted above,Code:
awk '$2 ~ /R[0-9]/ { $1=""; p = $2 } $2 !~ /R[0-9]/ { sub( /\*/, "" ) $0 = sprintf( "\t\t\t%s %s %s\n", p, $1, $2 ) }1' filename
the code should be modified.Last edited by radoulov; 10-31-2007 at 11:30 AM. Reason: changed ...
- 10-31-2007 #5Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
Some times the Path\To\Backup A: will have spaces in it. like: To\Backup for A: wtih some info\user
They can be long but that is the only thing on that line.. I only need up to that the \user anything after that can be removed.
- 10-31-2007 #6
- 10-31-2007 #7Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
Some times they are longer then that.Code:* R0000001 Main 1.0.0.1 Active Some of the Backup Sets have not run since Oct 10, 2007 * COMPUTER01\Backup of files on D$\administrator Oct 10, 2007 Successful * SERVER01\Backup of files on P$\administrator Oct 10, 2007 With Errors (26) * CLINET01\Backup of System State and Services Database\administrator Oct 10, 2007 Successful
In the script you posted up what does this do:
Is it looking for the star? Because I can strip the stars out. I don't care what it looks like I would prefer it look like something:Code:sub( /\*/, "" )
Code:R0000001 COMPUTER01\Backup of files on D$\administrator R0000001 SERVER01\Backup of files on P$\administrator R0000001 CLINET01\Backup of System State and Services Database\administrator R0000002 COMPUTER01\Backup of files on D$\administrator R0000002 SERVER01\Backup of files on P$\administrator R0000002 CLINET01\Backup of System State and Services Database\administrator
- 10-31-2007 #8Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
I can run the report using tab to separate everything so -F"\t" could be used if that would help any.
- 10-31-2007 #9Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
Through the joys of what I have learned here I have made some changes to the output of the file to be a little more friendly I believe.
Hopefully this will make writing the part of the R# all the way down easier. So that it will look like my previous post. While I am waiting for help I am trying to find out the solution using what radoulov has posted earlier. I want to see if what he comes up with works the same way I am able if I can.Code:R0000001 Main 1.0.0.1 Active No Backup Sets have run: SERVER\Exchange Server 2007\administrator Oct 29, 2007 Successful SERVER\SQL Server MIP\backup_admin Oct 29, 2007 Successful SERVER\SQL Server CAUW001\backup_admin Oct 29, 2007 Successful SERVER\System State and Services Database\backup_admin Oct 29, 2007 Successful SERVER\Test\backup_admin Oct 29, 2007 Successful SERVER\System State and Services Database\backup_admin Oct 29, 2007 Successful R0000002 Main 1.0.0.1 Active No Backup Sets have run: SERVER\Backup of Microsoft Exchange Server\backup_admin Oct 25, 2007 Successful SERVER\Backup of files on E$,System State and Services Database\backup_admin Oct 25, 2007
- 10-31-2007 #10Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
I got it! I made it work. I got the information I want and now all I have to do is format it.


Reply With Quote
