Record count problem using sed command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Record count problem using sed command
# 1  
Old 07-02-2008
Tools Record count problem using sed command

Hi,

I have a script which removes 2 header records and 1 trailer record in a list of files. The commands doing the actions are
sed '1,2d' $file > tempfile1.dat
sed '$d' < tempfile1.dat > $output.txt

Its working fine for all records except a file having size=1445509814 and number of records=13152342. The output has only 5297671 records instead of being just 3 less than the original count.
Is there any limitation on the number of records that the sed command can process?
Some details-
>uname -a
SunOS xx 5.10 SunOS_Development sun4u sparc SUNW,Sun-Fire

>df -k .
Filesystem kbytes used avail capacity Mounted on
xx 67091946 64377506 2043521 97% xx


>df -k /tmp
Filesystem kbytes used avail capacity Mounted on
swap 17337536 1504840 15832696 9% xx
# 2  
Old 07-02-2008
What happens if you use the following?
Code:
sed -e '1,2d' -e '$d' $file > $output.txt

# 3  
Old 07-02-2008
MySQL

Its working in a similar way, just the number of records now generated is a bit more. I think its the problem of lack of space. As the box gets almost filled up when the code runs. When more space is available the output record count is also more.
Thanks a lot anyway!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with Getting distinct record count from a .dat file using UNIX command

Hi, I have a .dat file with contents like the below: Input file ============SEQ NO-1: COLUMN1========== 9835619 7152815 ============SEQ NO-2: COLUMN2 ========== 7615348 7015548 9373086 ============SEQ NO-3: COLUMN3=========== 9373086 Expected Output: (I just... (1 Reply)
Discussion started by: MS06
1 Replies

2. Shell Programming and Scripting

Validating the record count

Hi , I am having a text file with several records., it has a header record and trailer record. The header record has the number of rows (records) found in the text file and time-stamp. The footer record has the total number of records ( along with the header and trailer., Suppose: wc -l... (4 Replies)
Discussion started by: cratercrabs
4 Replies

3. UNIX for Dummies Questions & Answers

Grep char count & pipe to sed command

Hi I am having a 'grep' headache Here is the contents of my file: (PBZ,CP,(((ME,PBZ,BtM),ON),((ME,((PBZ,DG),(CW9,PG11))),CW9,TS2,RT1))) I would like to count out how many times 'PBZ' occurs and then place that number in the line above 3... (8 Replies)
Discussion started by: cavanac2
8 Replies

4. Shell Programming and Scripting

Validate record count

Hi all How to verify the number of records in case of delimited file, If the file has records. And then if it is not equal to mentioned no. of records, email is triggered and file is moved to bad directory path. Example ----- input file = a.txt bad directory path : /usr/bin/bad (6 Replies)
Discussion started by: balaji23_d
6 Replies

5. Shell Programming and Scripting

replaying a record count with another record count

i use unix command to take the record count for a file1 awk 'END{print NR}' filename i already have a file2 which conatin the count like ... .. rec_cnt=100 .. .. I want to replace the record in the file2 using the record i take from file1. suggest me some simple ways of doing it... (2 Replies)
Discussion started by: er_zeeshan05
2 Replies

6. Shell Programming and Scripting

Sed command dropping last record in File

Hello: I wrote a sed statement that is inserting 3 variables at the beginning of each record in a comma-delimited file: for FILE in *gnrc_lkup.csv do c=`echo $FILE | cut -c1-3` d=`grep $c $RTLIST | cut -c4-6` e=`grep $c $RTLIST | cut -c7` f=`grep $c $RTLIST | cut -c8` sed -e... (5 Replies)
Discussion started by: bheeke
5 Replies

7. UNIX for Dummies Questions & Answers

Problem count with wc-l command

Hi All, I'm trying to count how many line in my *.txt file. My *.txt file has 1937 lines. The problem is : when I use wc -l command the result is 1936. Again, I did some test. I create a new file with 100 lines with text editor (Notepad ++, Ultra edit). And when I count it again with wc... (2 Replies)
Discussion started by: kunimi
2 Replies

8. Shell Programming and Scripting

record count

i have a file named file_names.dat where there are several files along with their path. exp: /data1/dir1/CTA_ACD_20071208.dat /data1/dir1/CTA_DFG_20071208.dat i want to write a script which will create a csv file with the name of the file and record count of that file the output file... (4 Replies)
Discussion started by: dr46014
4 Replies

9. Shell Programming and Scripting

Usiung last record of file using 'sed' command

Hi, In my Scripts,i need to read record from a file and after reading I need to delete that record,as I need to run the script in a loop for no of records in file.( I am using While-do command for that).But my problem is while deleting record using command"`cat ${TEST_FILE}|sed '$d' >... (5 Replies)
Discussion started by: Roopanwita
5 Replies

10. UNIX for Dummies Questions & Answers

How to count the record count in an EBCDIC file.

How do I get the record count in an EBCDIC file on a Linux Box. :confused: (1 Reply)
Discussion started by: oracle8
1 Replies
Login or Register to Ask a Question