Register
It is currently Sat Nov 01, 2014 1:39 am

Input file for GnuCash


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed Feb 29, 2012 10:47 am   

Joined: Wed Feb 29, 2012 10:45 am
Posts: 1
Can somebody give me a simple bash scrip that will make the first block of info look like the second block of info below. I've managed to take off the header and the footer, but I'm unable to change everything to a positive!

In general, this file would have a variable number of entries each time I download it from the bank. The header and footer however are always the same.

Thanks in advance! :)

Umsätze persönliches Konto (00);;;Kundennummer: 4562945739
26.08.2010 - 04.09.2010
Letzter Kontostand;;;;752,54;EUR
Buchungstag;Wert;Verwendungszweck;Soll;Haben;Währung
26.08.2010;26.08.2010;"EC TANKSTELLE AN DER B";-42,33;;EUR
01.09.2010;01.09.2010;"03/232347 KRANKENVERS";-511,97;;EUR
03.09.2010;03.09.2010;"KLEINHOLZ 3077/09";;376,97;EUR
04.09.2010;04.09.2010;"LOTTO";;1000,00;EUR
04.09.2010;04.09.2010;"LOTTO *STORNO*";-1000,00;;EUR
Kontostand;04.09.2010;;;575,21;EUR



26.08.2010;26.08.2010;"EC TANKSTELLE AN DER B";42,33;;EUR
01.09.2010;01.09.2010;"03/232347 KRANKENVERS";511,97;;EUR
03.09.2010;03.09.2010;"KLEINHOLZ 3077/09";;376,97;EUR
04.09.2010;04.09.2010;"LOTTO";;1000,00;EUR
04.09.2010;04.09.2010;"LOTTO *STORNO*";1000,00;;EUR


Top
 Profile  
 PostPosted: Wed Feb 29, 2012 7:19 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 552
hi,

this is not related to bash, it's a simple `egrep` to do.
see man 7 regex


Top
 Profile  
 PostPosted: Sat Mar 31, 2012 8:52 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
After your way of removing the header and footer:

Code:
awk -F\; -v OFS=\; '$4 < 0 { $4 = -$4 } 1' file



Editing the file, without removing the header, nor the footer:
Code:
ed -s < <(printf '%s\n' '5,$-1s/\(.*"\)\(;*\)-\(.*\)/\1\2\3/' w) file



Editing the file by removing the header and the footer, this time:
Code:
ed -s < <(printf '%s\n' 1,4d '$d' ',s/\(.*"\)\(;*\)-\(.*\)/\1\2\3/' w) file


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP