tail out of memory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tail out of memory
# 1  
Old 06-11-2009
tail out of memory

Hi,

I am performing a tail command on EBCDIC coded files and am getting the following error message when I try to process very large files.

Code:
tail: There is not enough memory available now.

The file in question has more than 10 millions lines.

I would like to ask for advice for getting around this issue. The reason why tail is used is because I am inserting new bytes in this file and concatenate the new elements with the rest of the file. The tail is performed on the total number of lines minus 1.

I am currently trying to make it work by using the split command on a 100 MB basis, running the tail command on the leading piece to build my workfile, then I do concatenate the result with the rest of the pieces. But I would like to ask for more alternatives as well in case I am proven wrong in my approach.

Any suggestions?
Thanks
# 2  
Old 06-11-2009
Code:
{
  read ## read and discard first line
  cat
} < FILE

# 3  
Old 06-11-2009
Hmmm first of all I have strong doubts about the performance of the while read loop, secondly the cat command will give me a corrupted file since the file is not ASCII encoded which will make most lines unreadable by the cat command.

Code:
cat: Cannot open KßÓÂðòððððHX.

Thanks for the input though.
# 4  
Old 06-11-2009
Quote:
Originally Posted by Indalecio
Hmmm first of all I have strong doubts about the performance of the while read loop,

There is no while read loop.
Quote:
secondly the cat command will give me a corrupted file since the file is not ASCII encoded which will make most lines unreadable by the cat command.

The cat command will read whatever is in the file; its encoding makes no difference. It handles binary files in exactly the same manner as text files: byte by byte.
Quote:
Code:
cat: Cannot open KßÓÂðòððððHX.


You didn't use the script I posted; in it, there is no file to be opened by cat; it is using redirection.
# 5  
Old 06-11-2009
Sorry for misunderstanding your point, I had my head around so many things that I missed it completely...

What you posted seems to work and performance is similar to my alternative solution using split/tail/cat, but in a much lighter format.

As far as I could see there are no difference between our output files so I may opt for the most simplistic solution aka yours.

Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining multiple files tail on tail

I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250. I would like to join all 250 of them together tail by tail as follows. For example stat.1000 a b c d e f stat.1001 g h i j k l So that my output... (2 Replies)
Discussion started by: kayak
2 Replies

2. Solaris

[DOUBT] Memory high in idle process on Solaris 10 (Memory Utilization > 90%)

Hi Experts, Our servers running Solaris 10 with SAP Application. The memory utilization always >90%, but the process on SAP is too less even nothing. Why memory utilization on solaris always looks high? I have statement about memory on solaris, is this true: Memory in solaris is used for... (4 Replies)
Discussion started by: edydsuranta
4 Replies

3. Solaris

relationship or difference between entitled memory and locked memory

Hello solaris experts, Being new to solaris containers, from Linux, feeling difficulty in understanding certain concepts. Hope somebody can help me here. I understand that, & some questions .... Locked memory -- memory which will not be swapped out at any cause. is this for... (0 Replies)
Discussion started by: thegeek
0 Replies

4. UNIX for Advanced & Expert Users

Out of Memory error when free memory size is large

I was running a program and it stopped and showed "Out of Memory!". at that time, the RAM used by this process is around 4G and the free memory size of the machine is around 30G. Does anybody know what maybe the reason? this program is written with Perl. the OS of the machine is Solaris U8. And I... (1 Reply)
Discussion started by: lilili07
1 Replies

5. Solaris

restrcit physical memory with zone.max-locked-memory

Is it possible to restrict physical memory in solaris zone with zone.max-locked-memory just like we can do with rcapd ? I do not want to used rcapd (1 Reply)
Discussion started by: fugitive
1 Replies

6. Programming

How to deal with lots of data in memory in order not to run out of memory

Hi, I'm trying to learn how to manage memory when I have to deal with lots of data. Basically I'm indexing a huge file (5GB, but it can be bigger), by creating tables that holds offset <-> startOfSomeData information. Currently I'm mapping the whole file at once (yep!) but of course the... (1 Reply)
Discussion started by: emitrax
1 Replies

7. Solaris

How to find Total and Free Physical Memory and Logical Memory in SOLARIS 9

Hi, Im working on Solaris 9 on SPARC-32 bit running on an Ultra-80, and I have to find out the following:- 1. Total Physical Memory in the system(total RAM). 2. Available Physical Memory(i.e. RAM Usage) 3. Total (Logical) Memory in the system 4. Available (Logical) Memory. I know... (4 Replies)
Discussion started by: 0ktalmagik
4 Replies

8. AIX

ulimits max locked memory virtual memory

Hi, Would any one be so kind to explain me : are ulimits defined for each user seperately ? When ? Specialy what is the impact of : max locked memory and virtual memory on performance of applications for a user. Many thanks. PS : this is what I can see in MAN : ulimit ] ... (5 Replies)
Discussion started by: big123456
5 Replies

9. Programming

how to round up a memory address(memory alignment problem)

Hi, I try to marshal a unsigned int and a char * into a buffer, and then unmarshal them later to get them out. I need to put the char * in the front and unsigned int at the end of the buffer. However, my system always give me "BUS ERROR". I am using Sun Sparcs Sloris 2.10. My code to marshal... (6 Replies)
Discussion started by: nj302
6 Replies

10. UNIX for Advanced & Expert Users

Shared memory shortage but lots of unused memory

I am running HP-UX B.11.11. I'm increasing a parameter for a database engine so that it uses more memory to buffer the disk drive (to speed up performance). I have over 5GB of memory not being used. But when I try to start the DB with the increased buffer parameter I get told. "Not... (1 Reply)
Discussion started by: cjcamaro
1 Replies
Login or Register to Ask a Question