Parsing large files in Solaris 11


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing large files in Solaris 11
# 1  
Old 08-18-2015
Parsing large files in Solaris 11

I have a 1.2G file that contains no newline characters. This is essentially a log file with each entry being exactly 78bits long. The basic format is /DATE/USER/MISC/. The single uniform thing about the file is that that the 8 character is always ":"

I worked with smaller files of the same data before using the following command

Code:
 ggrep -E -o ".{0,8}\:.{0,67}" LOG.txt

but the problem with this particular file is the size of the file itself. At 1.2G ggrep runs out of memory....

Code:
ggrep: memory exhausted

looking for a way to break up the file or get around the memory limits.
# 2  
Old 08-18-2015
Having an entry that is 78 bits long that contains characters is very strange. Most entries in a file are a stream of 8 bit bytes. So, to split your entries (each of which is 9.75 bytes) into 11 byte lines (your 9.75 bytes per entry plus 2 bits for byte packing and a newline so the output is a text file), you're probably going to find writing a C program to read bytes and rotate bits into the proper positions easier than doing it in a shell script.

What two bits should be added to your entries to produce 10 characters (assuming ASCII or EBCDIC) from your input entries?

If your entries are all 78 bits long, why is your grep looking for a varying number of characters before and after the colon and why is the string it is matching varying from 1 to 76 characters (not bits or bytes) inclusive instead of the 78 bits you specified???

Please show us the first 200 bytes of your input file piped through the command:
Code:
od -bcx

# 3  
Old 08-18-2015
Looking at the example I think OP meant 78 bytes Smilie
# 4  
Old 08-19-2015
If exists on your system, would
Code:
fold -w78 file

work?

Last edited by RudiC; 08-19-2015 at 03:22 AM..
# 5  
Old 08-19-2015
If the records are all of fixed size, dd can be used to insert a newline after them. An example with 4 byte fixed size records:

Code:
# bs is 1 minus the record size, cbs is the record size.
$ printf "AAA:BBB:CCC:DDD:" | dd bs=3 cbs=4 conv=unblock

AAA:
BBB:
CCC:
DDD:

$

dd is unaffected by line length limitations. You chould chain this before an awk or grep or what have you.

Code:
dd if=filename ... | grep whatever

# 6  
Old 08-19-2015
Quote:
Originally Posted by Corona688
If the records are all of fixed size, dd can be used to insert a newline after them. An example with 4 byte fixed size records:

Code:
# bs is 1 minus the record size, cbs is the record size.
$ printf "AAA:BBB:CCC:DDD:" | dd bs=3 cbs=4 conv=unblock

AAA:
BBB:
CCC:
DDD:

$

dd is unaffected by line length limitations. You chould chain this before an awk or grep or what have you.

Code:
dd if=filename ... | grep whatever

I assume you meant bs=4 instead of bs=3, but when processing a 1.2Gb file, dd will run noticeably faster with its default block size (512 bytes) or a larger size like bs=1024000. The dd bs=n parameter specifies how many bytes dd will read at a time from its input file and how many bytes at a time it will write to its output file.

With conv=unblock, it is just the conversion buffer size (specified by cbs=n) that determines the output line length produced by the dd utility.
# 7  
Old 08-19-2015
Quote:
Originally Posted by Don Cragun
I assume you meant bs=4 instead of bs=3
No, I meant bs=3. That is what it seemed to require from empirical testing.

Quote:
but when processing a 1.2Gb file, dd will run noticeably faster with its default block size (512 bytes)
You are correct. It appeared to require it but that was my mistake (probably from still using the sync option at the time).

You might even do bs=4M.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing a subset of data from a large matrix

I do have a large matrix of the following format and it is tab delimited ch-ab1-20 ch-bb2-23 ch-ab1-34 ch-ab1-24 er-cc1-45 bv-cc1-78 ch-ab1-20 0 2 3 4 5 6 ch-bb2-23 3 0 5 ... (6 Replies)
Discussion started by: Kanja
6 Replies

2. UNIX for Dummies Questions & Answers

How to display large file in Solaris?

Hi i want to see file in solaris which are eating space. like we have a listfiles command in AIX which show all the files in decreading order of the size . example of listfile command in this command i am able to all the huge file in root directory. do we have any similar command in... (1 Reply)
Discussion started by: scriptor
1 Replies

3. Shell Programming and Scripting

Help needed for parsing large XML with awk.

My XML structure looks like: <?xml version="1.0" encoding="UTF-8"?> <SearchRepository> <SearchItems> <SearchItem> ... </SearchItem> <SearchItem> ... ... (1 Reply)
Discussion started by: jasonjustice
1 Replies

4. UNIX for Advanced & Expert Users

Need help with configuring large packet size on Solaris 7 / e6500

We're running Solaris 7 on FDDI n/w on an E6500 host and wish to use MTU (packet size) > 1500, more like 3072 bytes to begin with and possibly up to 4096 bytes. Linux has /etc/network/interfaces. Does ANYONE remember the equivalent in Unix? When I do ifconfig eth0 mtu 4000, I get the error... (0 Replies)
Discussion started by: sharique
0 Replies

5. Solaris

How to safely copy full filesystems with large files (10Gb files)

Hello everyone. Need some help copying a filesystem. The situation is this: I have an oracle DB mounted on /u01 and need to copy it to /u02. /u01 is 500 Gb and /u02 is 300 Gb. The size used on /u01 is 187 Gb. This is running on solaris 9 and both filesystems are UFS. I have tried to do it using:... (14 Replies)
Discussion started by: dragonov7
14 Replies

6. Shell Programming and Scripting

Divide large data files into smaller files

Hello everyone! I have 2 types of files in the following format: 1) *.fa >1234 ...some text... >2345 ...some text... >3456 ...some text... . . . . 2) *.info >1234 (7 Replies)
Discussion started by: ad23
7 Replies

7. Shell Programming and Scripting

parsing large CDR XML file

Dear Freind in the file attached how parse the data to be like a normal table :D (3 Replies)
Discussion started by: saifsafaa
3 Replies

8. Shell Programming and Scripting

Parsing a large log

I need to parse a large log say 300-400 mb The commands like awk and cat etc are taking time. Please help how to process. I need to process the log for certain values of current date. But I am unbale to do so. (17 Replies)
Discussion started by: asth
17 Replies

9. Shell Programming and Scripting

Problem with parsing a large file

Hi All, Following is the sample file and following is the op desired that is the last entry of each unique first field is required. My solution is as follows However the original file has around a million entries and around a 100,000 uniques first fields, so this soln.... (6 Replies)
Discussion started by: gauravgoel
6 Replies
Login or Register to Ask a Question