Problem in deleting lines from the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in deleting lines from the file
# 1  
Old 10-08-2009
Problem in deleting lines from the file

Hi All

I am not able to delete few line from long file.

I have a big file which is of 53998 B in size i want to delete lines starting from 32768 to 53998 and collect remaining file in new file.

It is giving exception
sed: command garbled: 32768,$countd

Please find the sample script below

#!/bin/ksh
cd /usr/home/dfusr/backup
typeset myLogFile=pe_proxy_master_2160.Wed.log
typeset myFile=aaa.log
typeset -i count=0
count=$(cat pe_proxy_master_2160.Wed.log | wc -c)
echo "COUNT:: $count"
if [ count -gt 32767 ]
then
sed '32768,"$count"d' "$myLogFile" > "$myFile"
fi

COUNT:: 53998

Please advice where i am doing wrong
# 2  
Old 10-08-2009
i want to delete lines starting from 32768 to 53998

Code:
sed '32768,53998'd

# 3  
Old 10-08-2009
Code:
sed "32768,${count}d" "$myLogFile" > "$myFile"

Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting last 3 lines from a file via sed

Hi Anybody can help me to delete the last 3 lines from a text file via sed under SunOS 5.8? Thanks Aldar (4 Replies)
Discussion started by: aldar
4 Replies

2. Shell Programming and Scripting

deleting specific lines in a file

Hello, I have a file like: 26-07-2011 sunz02 message1 26-07-2011 sunz02 message2 26-07-2011 sunz02 message3 15-07-2011 sunz02 message1 15-07-2011 sunz02 message2 15-07-2011 sunz02 message3... (5 Replies)
Discussion started by: asanchez
5 Replies

3. Shell Programming and Scripting

deleting lines in a log file

Hello Community, sorry iam from germany and my englisch is not so well. iam searching for less then 4 hours on the web for a solution of my problem. i have a proxy-log-file and want to delete lines wicht matches on two words. example of the line in the logfile: now i want to delet... (3 Replies)
Discussion started by: matze
3 Replies

4. Shell Programming and Scripting

deleting lines from file

We have a server that logs transactions to a file. I want to write a script that will delete the first 50 lines of the file daily without renameing the file or moving the file. (8 Replies)
Discussion started by: daveisme
8 Replies

5. UNIX for Advanced & Expert Users

Deleting lines from a file

How I can delete 100 lines anywhere in a file without opening a file and without renaming the file. (11 Replies)
Discussion started by: Nirgude07
11 Replies

6. UNIX for Dummies Questions & Answers

Deleting whole lines from a file

I have a file with 65 sets of 35 coordinates, and would like to isolate these coordinates so that I can easily copy the coordinates to another file. The problem is, I've got a 9 line header before each set of coordinates (so each set is 44 lines long). There are a zillion threads out there about... (3 Replies)
Discussion started by: red baron
3 Replies

7. UNIX for Dummies Questions & Answers

Deleting lines in text file

Hi everyone, I have text files that I want to delete lines from. I have searched through this forum for quite some time and found examples of both awk and sed. Unfortunately, I was not able to successfully do what I want. Well to some extent. I did manage to delete the first 15 lines from each... (5 Replies)
Discussion started by: hern14
5 Replies

8. Shell Programming and Scripting

Deleting lines in a file

How do I delete all the lines after the line containing text ***DISCLOSURES*** . I want to delete this line too. Thank you (2 Replies)
Discussion started by: reachsamir
2 Replies

9. Shell Programming and Scripting

Deleting last 2 lines from the file.

Hi I have a file & always I need to remove or delete last 2 lines from that file. So in a file if I have 10 lines then it should return me first 8 lines. Can someone help me? (4 Replies)
Discussion started by: videsh77
4 Replies

10. Shell Programming and Scripting

deleting lines in a log file

Is there an easy way to delete the first so many lines in a log file? like I have a log file that has 10000 lines, i want to just get rid of the first 9000. (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies
Login or Register to Ask a Question