LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-23-2002, 02:03 AM   #1
doublefailure
Member
 
Registered: Mar 2002
Location: ma
Distribution: slackware
Posts: 747

Rep: Reputation: 30
help this to make this sed efficient plz


hi..
i'm a newbie to sed..

i'm gonna run this script on really really big file
(almost 1gig)

i think it should be really efficient
could u guys help me out?

thankyou !!

--------------------------------------------
#! /bin/bash
inputfile=$1

sed -e 's/<Topic r:id=\"//g' $inputfile |
sed -e 's/\">$//g' |
sed -e 's/\"\/>$//g' |
sed -e 's/<tag catid=\"//g' |
sed -e 's/^\".*//g' |
sed -e 's/<d:Title.*$//g'|
sed -e 's/<link r:.*$//g' |
sed -e 's/<\/Topic>//g' |
sed -e 's/<ExternalPage about\=\"//g' |
sed -e 's/<description>//g' |
sed -e 's/<\/description>//g' |
sed -e 's/<\/ExternalPage>//g' |
sed -e 's/^$//g' |
#sed -e 's/^Top.*\n$//g' |
awk '{
if ( $0 ~ /^Top/ )
printf("%s ", $0)
else
print $0
}' |

sed -e '/^$/d'
------------------------------------------

thank you!
 
Old 03-25-2002, 06:57 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
I don't think it's that inefficient. You are passing the data through pipes so it will just have to read the file from disk once. You just need to add something like "> newfile" to the end. Because the way you have it now you'll just get everything on stdout. However you will need an extra gig free to write the newfile.
You can run multiple commands with one sed call though which might speed things up a bit.

Ex:
cat numbers | sed -e '/one/two/' -e '/three/four/'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how i can make my second HD detectable (plz i need help) h3llz0r Linux - Hardware 13 12-10-2005 01:41 PM
Simple is efficient ???? Maybe/Maybe not ! bigjohn General 21 07-08-2005 10:27 AM
a more efficient set up dr_zayus69 Linux - Newbie 3 12-03-2004 09:47 AM
mysql::DBD make problems - help plz pigsy Linux - Software 15 04-17-2004 02:48 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration