473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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
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 1666
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

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

Similar topics

2
by: Todd Moyer | last post by:
I would like to use Python to parse a *python-like* data description language. That is, it would have it's own keywords, but would have a syntax like Python. For instance: Ob1 ('A'): Ob2...
10
by: Michael McCracken | last post by:
Hi, I have a problem with unittest.TestCase that I could really use some help with. I have a class File in module File. The important thing about File for this discussion is that it's simple -...
8
by: Francois Grieu | last post by:
I guess this program has undefined behavior, as far as ISO C is concerned. Anyone knows an implementation where realloc actually moves a block that it shortens (as opposed to grows?) ...
4
by: Hugh | last post by:
Hello, I am having some problems understanding (most likely), parsing a text file. I would like to parse a file like: block1 { stuff; ... stuffN; };
1
by: Michiel Sikma | last post by:
Hello everybody. Inspired by an example from the book Beginning Python: From Novice to Professional, I started working on a simple text parser which I can hopefully then extend into a more...
4
by: Dave | last post by:
TIA for the help.....this should be easy for a pro....I need the two divs with text to display on the same line at the top of the container..??? <html> <head> <style> body...
2
by: Bob Greschke | last post by:
This is the idea Block = pack("240s", "") Block = pack(">H", W) Block = pack(">H", X) Block = pack(">B", Y) Block = pack(">H", Z)) but, of course, Block, a str, can't be sliced. The real...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
5
by: amjadcsu | last post by:
I am a newbie in python I am trying to parse a xml file and write its content in a txt file. The txt contains null elements. Any reason what iam doing wrong here Here is the code that i wrote...
31
by: broli | last post by:
I need to parse a file which has about 2000 lines and I'm getting told that reading the file in ascii would be a slower way to do it and so i need to resort to binary by reading it in large...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.