I have many files which contain about two million lines.
Now I want to use sed to delete the 9th line and add a new
line behind the 8th line. I use the command as follows:
But it is very slow for every file.
Does anybody have a better way to do that?
thank you.
Last edited by Scott; 02-04-2013 at 02:21 PM..
Reason: Please use code tags
You are reading, overwriting, and deleting the entire file each loop. ...Twice.
Unfortunately if the file is huge, this may never be fast, because you cannot really avoid having to write all the old data. Files do not have an 'insert' or 'delete' operation for data in the middle of them, all the data after the change must be rewritten in the new spot.
This avoids needing to alter the file twice by just printing an alternate line for line 9 instead of deleting then inserting.
Hi
We are using sed to clean up a file of a pattern and its talking a lot of time on XML output file
The command that we are using is
sed -e "s/tns1://g" $OUTPUTFILENM > $TEMPFILE
Where $OUTPUTFILENM is the file to be cleaned and $TEMPFILE is the cleaned output
Can you... (3 Replies)
HI Experts ,
I'm using the following code to remove spaces appearing at the end of the file.
sed "s/*$//g" <filename> > <new_filename>
mv <new_filename> <filename>
this is working fine for volumes upto 20-25 GB.
for the bigger files it is taking more time that it is required... (5 Replies)
Hi,
I have a script that, basically, has two input files of this type:
file1
key1=value1_1_1
key2=value1_2_1
key4=value1_4_1
...
file2
key2=value2_2_1
key2=value2_2_2
key3=value2_3_1
key4=value2_4_1
...
My files are 10k lines big each (approx).
The keys are strings that don't... (7 Replies)
Hi I am using a cut command in the script which is slowing down the performance of the script .can anyone suggest the other ways of doing the same cut command
Record_Type=`echo "$line" | cut -c19-20`
*******this is slowing down*********
i have 4 more cut commands
2 in one loop and 2 in inner... (3 Replies)
Hi All,
I have problem when i write my user name to login to my server late (about 10 min) to give me field of password
if u know how i can solve it?
Thanks (4 Replies)
Hi,
I have an SCO-Unix server running.
There are some processes (unknown to me) which consume a lot of the system resources. This slows down the server dramatically.
Is there a command or program that monitors what processes are using the cpu, disk, etc.. and tell me how excessive and how... (3 Replies)
Discussion started by: Hansaplast
3 Replies
7. Post Here to Contact Site Administrators and Moderators