473,379 Members | 1,123 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,379 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 1665
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

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

Similar topics

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...
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 -...
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?) ...
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; };
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...
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...
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...
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...
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...
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...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.