Sponsored Content
Top Forums Shell Programming and Scripting Help with parsing a unorganized file Post 302770105 by crypto87 on Thursday 14th of February 2013 12:50:44 PM
Old 02-14-2013
Wrench Help with parsing a unorganized file

I have a file which is of this format

Code:
ABCD1
,1,22,green,2013-02-14,09:00:00,true
,1,22,red,2013-02-14,09:00:00,true
,1,22,blue,2013-02-14,09:00:00,true
ABCD2
,1,22,yellow,2013-02-14,09:00:00,true
,1,22,white,2013-02-14,09:00:00,true
,1,22,blue,2013-02-14,09:00:00,true
ABCD3
,1,22,black,2013-02-14,09:00:00,true
,1,22,pink,2013-02-14,09:00:00,true

I want to generate a file as below using unix commands

Code:
ABCD1,1,22,green,2013-02-14,09:00:00,true
ABCD1,1,22,red,2013-02-14,09:00:00,true
ABCD1,1,22,blue,2013-02-14,09:00:00,true
ABCD2,1,22,yellow,2013-02-14,09:00:00,true
ABCD2,1,22,white,2013-02-14,09:00:00,true
ABCD2,1,22,blue,2013-02-14,09:00:00,true
ABCD3,1,22,black,2013-02-14,09:00:00,true
ABCD3,1,22,pink,2013-02-14,09:00:00,true


Last edited by joeyg; 02-14-2013 at 02:23 PM.. Reason: Please wrap commands and data with CodeTags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

2. Shell Programming and Scripting

need help in Parsing a CSV file and generate a new output file

Hi Scripting Gurus, I am trying to parse a csv file and generate a new output file. The input file will be a variable length in turns of rows and columns. output file will have 8 columns. we have three columns from the header for each set. just to give little bit more clarification each row... (15 Replies)
Discussion started by: vkr
15 Replies

3. Shell Programming and Scripting

Perl parsing compared to Ksh parsing

#! /usr/local/bin/perl -w $ip = "$ARGV"; $rw = "$ARGV"; $snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw"; $snmpw = "/usr/local/bin/snmpwalk -Os -c $rw"; $syst=`$snmpg $ip system sysName sysObjectID`; sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies

4. Shell Programming and Scripting

Parsing File

I have input file like Count(*) TableName ----------- ------------------------------ 1 ccc_customers Count (*)TableName ----------- ------------------------------ 1 ccc_conduit_gci , I want to take only lines with 1 starting letter and removeing the 1 and spaces OUTPUT... (8 Replies)
Discussion started by: scorp_rahul23
8 Replies

5. UNIX for Dummies Questions & Answers

Script for parsing details in a log file to a seperate file

Hi Experts, Im a new bee for scripting, I would ned to do the following via linux shell scripting, I have an application which throws a log file, on each action of a particular work with the application, as sson as the action is done, the log file would vanish or stops updating there, the... (2 Replies)
Discussion started by: pingnagan
2 Replies

6. Shell Programming and Scripting

Parsing file, yaml file? Extracting specific sections

Here is a data file, which I believe is in YAML. I am trying to retrieve just the 'addon_domains" section, which doesnt seem to be as easy as I had originally thought. Any help on this would be greatly appreciated!! I have been trying to do this in awk and mostly bash scripting instead of perl... (3 Replies)
Discussion started by: Rhije
3 Replies

7. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

8. Shell Programming and Scripting

Parsing a file

Hi, I want to parse a file. The file looks like this: >ctg86 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX >ctg13 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX I want it to look like this: >ctg86... (2 Replies)
Discussion started by: phil_heath
2 Replies

9. Shell Programming and Scripting

parsing data from a big file using keys from another smaller file

Hi, I have 2 files format of file 1 is: a1 b2 a2 c2 d1 f3 format of file 2 is (tab delimited): a1 1.2 0.5 0.06 0.7 0.9 1 0.023 a3 0.91 0.007 0.12 0.34 0.45 1 0.7 a2 1.05 2.3 0.25 1 0.9 0.3 0.091 b1 1 5.4 0.3 9.2 0.3 0.2 0.1 b2 3 5 7 0.9 1 9 0 1 b3 0.001 1 2.3 4.6 8.9 10 0 1 0... (10 Replies)
Discussion started by: Lucky Ali
10 Replies

10. Shell Programming and Scripting

Need help parsing a file

Here is my file contents: I wish to generate <value-in-name-tag>.cfg which should contain entries like below Currently i am able to populate only what you see below. How can i also populate in the .cfg files ? Below is my code so far: grep -o '<name>.*</name>' deploy.tmp | sed... (1 Reply)
Discussion started by: mohtashims
1 Replies
EMPTY-PAGE(1)							 ExactImage Manual						     EMPTY-PAGE(1)

NAME
empty-page - empty page detector of the ExactImage toolkit SYNOPSIS
empty-page [option...] {-i | --input} input-file empty-page {-h | --help} DESCRIPTION
ExactImage is a fast C++ image processing library. Unlike many other library frameworks it allows operation in several color spaces and bit depths natively, resulting in low memory and computational requirements. empty-page counts dark pixels of a black and white image and decides with a threshold whether the page is most probably empty, and thus can be removed from the image processing stream. OPTIONS
-i file, --input file Read image from the specified file. -m n, --margin n Set width of border margin to skip. For speed reasons, the margin has to be a multiple of 8. The default is 16. -p x, --percentage x Set fraction of permissible dark pixels. The default is 0.05 (5%). -h, --help Display help text and exit. EXAMPLES
$ empty-page -i test.tif The image has 75461 dark pixels from a total of 1060992 (7.11231%). non-empty EXIT STATUS
The exit status is 0 if the image is mostly white, 1 otherwise. SEE ALSO
exactimage(7) AUTHORS
Jakub Wilk <jwilk@debian.org> Wrote this manual page for the Debian system. http://www.exactcode.de/site/open_source/exactimage/ This manual page incorporates texts found on the ExactImage homepage. COPYRIGHT
This manual page was written for the Debian system (and may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or (at your option) any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-2. empty-page 09/09/2013 EMPTY-PAGE(1)
All times are GMT -4. The time now is 02:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy