Sponsored Content
Top Forums Shell Programming and Scripting [Solved] awk command to read sequentially from a file until last record Post 302816755 by Corona688 on Tuesday 4th of June 2013 01:37:36 PM
Old 06-04-2013
Actually, it means exactly what it says... Too many open files. The close() isn't working for some reason. Memory usage is a nonissue, since we're not actually storing anything in memory.

I think the close should come first, otherwise it will never close the previous file, just the current one (which gets immediately reopened).

Code:
awk '/Generated/ && ofile {close(ofile)}
                  /Generated/ {ofile=sprintf("file%04d", ++cnt) ; next}
                  {print $0 > ofile) } '  inputfile


Last edited by Corona688; 06-04-2013 at 02:50 PM..
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read record from file

Hi all I have file f1 like this: Set AM/PM indicator to PM started|14155| Generate Error Re|7| Projected Cash Ba|741| Roll System Date |4| Projected Cash Balances started|2| Process Mark To Market started|13429| Process paydowns started|14189| Process Fixed Inc|439| Process Mark To... (3 Replies)
Discussion started by: koti_rama
3 Replies

2. UNIX for Dummies Questions & Answers

how to read record by record from a file in unix

Hi guys, i have a big file with the following format.This includes header(H),detail(D) and trailer(T) information in the file.My problem is i have to search for the character "6h" at 14 th and 15 th position in all the records .if it is there i have to write all those records into a... (1 Reply)
Discussion started by: raoscb
1 Replies

3. Shell Programming and Scripting

Read the record from a text file

Hi I want to read one row record from a text file. For eg: I have Sample.txt file with one row of record like 123456768 I want to get the above value from the file and assign it to a variable in my script. Please guide me how to proceed. Thanks, Soll (2 Replies)
Discussion started by: sollins
2 Replies

4. Shell Programming and Scripting

Read a input file and insert it to UDB sequentially

Guys, I'm very new to Unix script. I need to add some logics into the existing script. Read a record 1) if it's a header record then verify the file sequence no aginst the file sequence no in UDB control table. 2) if Step 1 is ok then CONNECT UDB otherwise stop or abend. 3) if... (0 Replies)
Discussion started by: Sunny TK Sun
0 Replies

5. Shell Programming and Scripting

[Solved] awk manipulation of sequentially named files

Hello, I am a very novice user of awk, I have a set of files named file001, file002, file003, file004, etc., each contains four fields (columns of data) separated each by a uneven number of spaces. I want to substitute those spaces by a TAB, so I am using this line of awk script: awk -v OFS="\t"... (4 Replies)
Discussion started by: jaldo0805
4 Replies

6. Shell Programming and Scripting

Read input file with in awk script not through command line

Hi All, Do we know how to read input file within awk script and send output toanother log file. All this needs to be in awk script, not in command line. I am running this awk through crontab. Cat my.awk #!/bin/awk -f function test(var){ some code} { } END { print"test code" } (5 Replies)
Discussion started by: random_thoughts
5 Replies

7. Shell Programming and Scripting

awk command to omit trailer record in a file

I am trying to omit the trailer record in a variable width file I tried using awk 'NR >1 { print prev } { prev = $0 }' filename The above command is giving output but somehow it is trimming columns from the record. For example if my record has columns A,B,C,D The awk gives output as A,B,C ... (4 Replies)
Discussion started by: abhilashnair
4 Replies

8. UNIX for Beginners Questions & Answers

awk command to retrieve record 23 and 89 from UNIX file

Hi Everyone, I am looking for awk command to retrieve only the record number 23 and record number 89 from a unix file? Please let me know what is the awk command for this? Regards Rakesh (1 Reply)
Discussion started by: rakeshp
1 Replies

9. Homework & Coursework Questions

awk command to retrieve record 23 and 89 from UNIX file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am looking for awk command to retrieve only the record number 23 and record number 89 from a unix file?... (6 Replies)
Discussion started by: rakeshp
6 Replies

10. Shell Programming and Scripting

Pass an array to awk to sequentially look for a list of items in a file

Hello, I need to collect some statistical results from a series of files that are being generated by other software. The files are tab delimited. There are 4 different sets of statistics in each file where there is a line indicating what the statistic set is, followed by 5 lines of values. It... (8 Replies)
Discussion started by: LMHmedchem
8 Replies
fsx(8)							      System Manager's Manual							    fsx(8)

Name
       fsx - file system exerciser

Syntax
       /usr/field/fsx [ -h ] [ -ofile ] [ -tn ] [ -fpath ] [ -pm ]

Description
       The exerciser exercises a file system by spawning up to 250 (the default is 20) processes that create, open, write, close, open, read, val-
       idate, close, and unlink a test file.  These test files are created in (the default) unless the -fpath option is used. The  exerciser  will
       run until or kill -15 pid is sent to the process.

       A  logfile is made in for you to examine and then remove. If there are errors in the logfile, make sure you check the file, because that is
       where the driver and kernel error messages are saved.

Options
       The options are:

       -h     Print the help messages for the command.

       -ofile Save the output diagnostics in file.

       -tn    Run time in minutes (n).	The default is to run until the process receives a or a kill -15 pid.

       -pm    Number (m) of processes to spawn.  The maximum is 250; the default is 20.

       -fpath Path name of directory on file system you wish to test.  For example, or The default is

Examples
       The following example runs 10 processes on until the process receives a or kill -15 pid:
       % /usr/field/fsx -p10 -f/mnt
       The following example runs 20 processes on for 120 minutes in the background:
       % /usr/field/fsx -t120 &

Restrictions
       If there is a need to run a system exerciser over an NFS link or on a diskless system there are some  restrictions.   For  exercisers  that
       need  to  write into a file system, such as the target file system must be writable by root.  Also the directory, in which any of the exer-
       cisers are executed, must be writable by root because temporary files are written into the current directory.   These  latter  restrictions
       are sometimes difficult to overcome because often NFS file systems are mounted in a way that prevents root from writing into them.  Some of
       the restrictions may be overcome by copying the exerciser to another directory and then executing it.  Avoid using the  exerciser  over	an
       NFS or diskless file system.

See Also
       Guide to System Exercisers

																	    fsx(8)
All times are GMT -4. The time now is 06:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy