troubleshooting Question

AWK in shell scripting

Avatar of harris2107
harris2107 asked on
Unix OS
7 Comments1 Solution3499 ViewsLast Modified:
Hi all,
          I am working on a shell script to extract information from a file that has output from sqlplus. The problem is the output of  a single line is spread across multiple lines and i do  not know as how to extract the particular filed at ones,which spans multiple lines. Following is what the file looks like from which i am trying to extract information.

DB1       Jack_                 Harris_
              Anderson          Godwin

DB2       RIck                    Rice
DB3       Adam                 Kelly

DB4      Paul_                  Darren_
             Collin                  Gough


As you can see from the file above, the output is skewed. In the first line the second column has name Jack_Anderson, which is divided in to two lines and there is a blank line between row1 and row 2. My question is how can i extract the individual fields. For eg: the $2 on first line should give me Jack_Anderson and $NR==2 is a blank line, how can i eliminate this in the search to get the exact information? I am using AWK to extract the required complete fields, can anyone shed light on this. I am writing this in KORN shell.

Thanks,
Harris
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros