The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sorting an ascii file shes UNIX for Dummies Questions & Answers 2 10-08-2008 06:11 AM
How to convert English text file to ASCII File? laknar Shell Programming and Scripting 1 07-23-2008 09:37 AM
Strange difference in file size when copying LARGE file.. 0ktalmagik Filesystems, Disks and Memory 1 06-03-2006 07:34 PM
ASCII file sherbet808 UNIX Desktop for Dummies Questions & Answers 1 06-13-2003 09:46 PM
How can I ... (Modifying large ASCII files) hviktor UNIX for Dummies Questions & Answers 2 07-20-2001 10:28 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-24-2008
fahoo fahoo is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
Formatting large Ascii file

Hi, I've got a very large ASCII file (1.5 GB), which doesn't have line terminators, making it impossible to read it right, i need to format it like:
add line terminators.
delete some lines on the file.
delete some fields on all the remainings lines (can be identified by a string).

After getting the file under the correct format i will inject it into a mysql DB, file details:

ASCII text, with very long lines, with no line terminators, i already tried tr and sed , but i cannot get it right.

hexdump head:

0000000 3136 3937 3934 3134 2032 2020 2020 4120
0000010 5249 2020 4d54 2053 4120 5249 2020 3137
0000020 3131 3131 2030 2020 2020 2020 2020 2020
0000030 2020 2020 2020 2020 2020 2020 2020 2020
*
0000070 2020 2020 2020 2020 2020 2020 3032 3730
0000080 3231 3732 3031 3131 3934 3032 3730 3231
0000090 3732 3330 3030 3030 3130 3038 3130 2020
00000a0 3236 3137 3630 3638 2030 2020 2020 4120
00000b0 5249 2020 4d54 2053 4120 5249 2020 3137
00000c0 3131 3131 2030 2020 2020 2020 2020 2020
00000d0 2020 2020 2020 2020 2020 2020 2020 2020
*
0000110 2020 2020 2020 2020 2020 2020 3032 3730
0000120 3231 3732 3031 3131 3934 3032 3730 3231
0000130 3732 3231 3030 3030 3130 3038 3130 2020
0000140 3236 3537 3332 3737 2036 2020 2020 4120
0000150 5249 2020 4d54 2053 4120 5249 2020 3137
0000160 3131 3131 2030 2020 2020 2020 2020 2020
0000170 2020 2020 2020 2020 2020 2020 2020 2020
*

--

Best regards.
  #2 (permalink)  
Old 10-24-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
You will have to write a dd command or maybe C or perl, something like that. Most Unix tools have a limit to line size.


How is the format supposed to be? We need examples of input and expected output.
  #3 (permalink)  
Old 10-24-2008
fahoo fahoo is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
examples.

Thanks for your reply, Example input, keep in mind it doesn't have line terminators , so when you open it on big terminals it get imposible to read:

617955555 AIR TMS AIR 7111110 2007122710114920071227030000018001 627166666 AI
R TMS AIR 7111110 2007122710114920071227120000018001 627577777 AIR TMS AIR 7111
110 2007122710114920071227120000018001 627588888 AIR AME AIR 7311110
2007122710114920071227030000018001 627599999 AIR AME AIR 7311110

example output:

617955555 AIR TMS AIR
627166666 AIR TMS AIR
627577777 AIR TMS AIR
627588888 AIR AME AIR
627599999 AIR AME AIR

Best regards.
  #4 (permalink)  
Old 10-24-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
dd is your friend.
Start with this:
Code:
dd ifile=inputfilename ofile=outputfilename cbs=22 conv=unblock
It is late for me - play around with the 22 block size until it works. I think your input block size is 22 with byte 22=space. Read the dd manpage.
  #5 (permalink)  
Old 10-26-2008
fahoo fahoo is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
Done!

cbs=20 did the magic, then sed '/^6/ !d' , best regards.
Closed Thread

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:38 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