469,315 Members | 1,414 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

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
Name:Non_Truncated_Name
Status:Stopped
Full Name:

Type:Windows OS
Name:Truncated_Name
Status:Started
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 1498
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
  4.  
  5. line="";
  6.  
  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;
  16.  
  17. echo $line
  18.  
Nov 15 '10 #2
RonB
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 zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.