471,830 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,830 software developers and data experts.

Parsing a Block of Test

The text from stdout and looks like the following and repeats the same four lines of data for every instance found from command tacmd listsit -m $thismanagedsystem -l

Type:Windows OS
Full Name:

Type:Windows OS
Full Name:This_is_the_full_name

What I am trying to do is parse the data and grab everything on the right side of the colon add some additional text and then print it out as a single line.

the output line would look something like this:
server,product code,Type,Name,Full name

From what I seen in many posts, is looking for a word pattern over multiple lines, and trying those does not produce desired results
Nov 15 '10 #1
2 1542
Expand|Select|Wrap|Line Numbers
  1. #try this in a linux shell
  2. #put your records in a text file called MYTEXT.txt
  3. #for loop will grab every non empty line and #concatenate with a comma
  5. line="";
  7. for i in $(cat MYTEXT.txt);
  8. do
  9.   r=$(echo "$i" |cut -d ':' -f 2);
  10.   if [[ $r != $empty ]];
  11.   then
  12.     #this is the place where handling your grabbed data
  13.     line="${line},${r}";
  14.   fi;
  15. done;
  17. echo $line
Nov 15 '10 #2
589 Expert Mod 512MB
What have you tried?

Are you receiving errors and if so, what are those errors?

You need to post your code.
Nov 15 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Todd Moyer | last post: by
10 posts views Thread by Michael McCracken | last post: by
8 posts views Thread by Francois Grieu | last post: by
1 post views Thread by Michiel Sikma | last post: by
2 posts views Thread by Bob Greschke | last post: by
13 posts views Thread by Chris Carlen | last post: by
5 posts views Thread by amjadcsu | last post: by
31 posts views Thread by broli | last post: by
reply views Thread by NeoPa | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.