Changing a Logfile

I like to change a file like here below
--------------------------------------------------------------
NET NAAM: 'FSW6';
              NODE(S): X1A.B12  S6.3 ;
 
NET NAAM: 'GND';
              NODE(S): G1.7  D5.7  D4.7  D3.7  D2.8  D1.8
                       V3.2  C3.2  R25.1  R20.1  R13.2  R18.2
                       R27.1  C10.2  C9.2  C8.2  C7.2  C6.2
                       C5.2  C4.2  C1.2  C2.2  X1A.B10  X1A.B6
                       X2A.B16  X2A.A20  X2A.A13  S16.B12
                       S16.B1 ;
--------------------------------------------------------------
I 've need a script sothat the file will be like here below
--------------------------------------------------------------
FSW6                   X1A.B12  S6.3
GND                    G1.7  D5.7  D4.7  D3.7  D2.8  D1.8
                       V3.2  C3.2  R25.1  R20.1  R13.2  R18.2
                       R27.1  C10.2  C9.2  C8.2  C7.2  C6.2
                       C5.2  C4.2  C1.2  C2.2  X1A.B10  X1A.B6
                       X2A.B16  X2A.A20  X2A.A13  S16.B12
                       S16.B1
--------------------------------------------------------------
I'm working on a SUNos system with a Csh shell scripts for
doing this only the problem is :
How can I get the line with NODE(S) on the back from the
line NET NAAM? Can I use sed for removing strings in more
then one line?
When somebody knows a solution for this give me
suggestions please. Thanks a lot for helping.

                Sigma
sigmaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leendertCommented:
Hi there,

here is a simple sed that will help you out :
Bare in mind that this small window does wrapping. The following
line is a one liner...

sed "s/NET NAAM: '//g;s/';//g;s/NODE(S): //g;s/;//g;/^$/d"

You will have to cat your logfile through this line of script.

Eg :
cat logfile | sed "s/NET NAAM: '//g;s/';//g;s/NODE(S): //g;s/;//g;/^$/d"



Output generated :
------------------

FSW6
  X1A.B12 S6.3  
GND
  G1.7 D5.7 D4.7 D3.7 D2.8 D1.8
  V3.2 C3.2 R25.1 R20.1 R13.2 R18.2
  R27.1 C10.2 C9.2 C8.2 C7.2 C6.2
  C5.2 C4.2 C1.2 C2.2 X1A.B10 X1A.B6
  X2A.B16 X2A.A20 X2A.A13 S16.B12
  S16.B1

If there is still a bit of tweeking needed please let me know.

Hope this will help you ...
Leendert.
0
leendertCommented:
Hi again,

After you applied the sed script I mentioned above,
you can also do the following script. If the names of the
node is always smaller than 6 characters this script will
change the format of the output file exactly as you wanted.

Here is the script :
cat logfile | while read A;
do
    Len=`echo $A | wc -c`
    if [ "$Len" -lt 6 ]
    then
        echo $A | tr -d '\n'
    else
        echo "  $A"
    fi;
done


Output generated :
FSW6  X1A.B12 S6.3
GND  G1.7 D5.7 D4.7 D3.7 D2.8 D1.8
  V3.2 C3.2 R25.1 R20.1 R13.2 R18.2
  R27.1 C10.2 C9.2 C8.2 C7.2 C6.2
  C5.2 C4.2 C1.2 C2.2 X1A.B10 X1A.B6
  X2A.B16 X2A.A20 X2A.A13 S16.B12
  S16.B1

Hope this solved your problem.

Leendert.
0
ahoffmannCommented:
this also is one linle in your shell:

cat file | sed -e '/^[@]*$/d;s/;//g' -n -e "/NET NAAM:/{;s/NET NAAM:'\(.*\)'/\1/;N;s/;//g;s/\n[@]*NODE(S)://p;n;};p"


``@''  above must be replaced by a blank followed by a tab.

But I would recommend to use (g)awk, because it will be much
faster (on Suns Solaris) than sed (I think you have huge
netlist files:-).

Ciao
Achim

Achim


0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

sigmaAuthor Commented:
Hi Leendert

First script is not working     >> Illegal variable name.
Second is also not working      >> while: Expression Syntax.

This is with shell command as in a script !!

  Sigma
0
ahoffmannCommented:
Sigma,

leendert's examples must be used in (k)sh.

> First script is not working >> Illegal variable name.
problem is the  ``$''  in the sed's subdtitute command. Replace
it by   ``$d''  and set a local csh-variable:

      set d = '$'

before evaluating the sed command.

> Second is also not working >> while: Expression Syntax.
This is sh syntax. Put it in a file and make it executable,
or rewrite with csh syntax, or simly start a sh and then execute.

Ciao
Achim
0
leendertCommented:
Thanks Achim for the above comments,

You're answer is better than mine in this case (csh compatible) :^). I missed that in the question. Better read the thing
more carefully next time ...

Leendert.
0
sigmaAuthor Commented:
Hi

It's working fine but I lose the lines without
NODE(S) and NET NAAM
I 'll find a solution for that.
Thanks a lot both of you Leendert & Achim

  Sigma
0
ahoffmannCommented:
If you loose the non-matching lines, you may have lost one of
the sed's  ``p''  commands (the last one), check it.
You can try omitting the  -n  option to the sed, you then should
get the  NET NAAM  lines twice.
Also note that bash doesn't allow typing a tab on the command
line (i.g. its used for file completion), just omit it if there
are no tabs in your file.

Achim
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ahoffmannCommented:
If you loose the non-matching lines, you may have lost one of
the sed's  ``p''  commands (the last one), check it.
You can try omitting the  -n  option to the sed, you then should
get the  NET NAAM  lines twice.
Also note that bash doesn't allow typing a tab on the command
line (i.g. its used for file completion), just omit it if there
are no tabs in your file.

Achim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.