The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiple input field Separators in awk. kinksville Shell Programming and Scripting 4 04-25-2008 06:12 PM
Creation of script,if the data file have more than one entry!!! bobprabhu Shell Programming and Scripting 1 02-07-2008 09:26 AM
How to get a data creation file superfabius UNIX for Dummies Questions & Answers 2 05-18-2007 11:33 AM
Get data creation file superfabius UNIX for Advanced & Expert Users 1 05-18-2007 10:05 AM
input of data ljdav2 Shell Programming and Scripting 3 09-05-2004 11:01 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-08-2009
Alexis Duarte Alexis Duarte is offline
Registered User
  
 

Join Date: Jun 2009
Location: Cape Verde
Posts: 12
Help with Creation of Script to Input Separators in Data

Hi all,
I have one problem that is preparing datas so I can run a script to extrat informations for my statistic reports.
I receive some datas, that are informations mixed and I need to separate them to analyse. This is an exemple of datas:

#header: 0MEPS000006000000051620090508001200905070010001613200020090508001
#body: 20421730007384620090507144018000001000000000A000000020283139Somewhere 00000001600
#body: 20421730007414520090507144237000001000000000A000000020283148Somewhere 00000001700
#body: .
#body: .
#body: .
#body: .
#body: .
#body: .
#tail: 9000000020000000000020000000000000000000000000000

Note that this #body, header does not include in this data.

So I receive them like this, but I need them to be like this:
0,MEPS,00000600,00000516,20090526001,20090525001,00016,132,000,20090526001,
2,04,2191,00112407,20090525233138,0000200000,00000,A,0000000502,98032,Somewhere ,020000008,0,0,
2,04,2191,00008894,20090525075812,0000010000,00000,A,0000001301,55245,Somewhere ,100000147,0,0,
.
.
.
.
9,00000059,0000000001790000,000000000000,000000000000,

So in this manner I can run my script:

#!/bin/bash
echo "
serial_nb amount date time ATM_nb location"
awk -F, '$1==2 {print$13,$7,$5,$6,$10,$12}' file_name

which produce me the results I want:

serial_nb amount date time ATM_nb location
000000016 0000010000 20090507 144018 0000000202 Somewhere
000000017 0000010000 20090507 144237 0000000202 Somewhere

So, right now I prepare my datas with the aid of excell, but I rather use an awk command to to this.
I need a command that says: input "," after 2 characters, then input another one after 5, etc etc.
Bottom line, a command that inputs separators acording to lenght.

Thanks for all your help.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0