The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
gcd.sh script doesn't work... kantze Shell Programming and Scripting 1 01-17-2008 09:46 PM
Modify Perl script to work with txt - Permissions script joangopan Shell Programming and Scripting 1 09-12-2007 11:38 PM
My script does not work - could you pls help? BearCheese Shell Programming and Scripting 1 06-29-2007 05:12 AM
Why does this script not work? Please help duke0001 Shell Programming and Scripting 4 02-22-2007 09:28 PM
Script doesn't work, but commands inside work cheongww UNIX for Dummies Questions & Answers 2 11-14-2006 10:52 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-02-2005
billy5 billy5 is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 9
sed script. How does it work?

I'm using this command
sed -e "s/'/'/g" -e 's/"/"/g' -e 's/&/\&/g' myfile.txt

My question is does this command reads file 3 times applying different replacement each time or it reads it only once and do 3 replacements at the same time?
My concern is, since I have big files (1 MB or more) that if its' first case - it will be very slow as list of different replacements grow. Have 3 now but can have 15 in a future!? Now it takes 45 minutes for 1mb file.


Thank you
  #2 (permalink)  
Old 09-02-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
the latter according to 'man sed'
Code:
     -e script script is an edit command  for  sed  .  See  USAGE
               below  for  more  information  on  the  format  of
               script. If there is just one -e option and  no  -f
               options, the flag -e may be omitted.

     -f script_file
               Take the script from script_file. script_file con-
               sists of editing commands, one per line.

     Multiple -e and -f options may be  specified.  All  commands
     are  added  to the script in the order specified, regardless
     of their origin.
  #3 (permalink)  
Old 09-02-2005
billy5 billy5 is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 9
Thanks, this explains it :
$ man sed
-----
A script consists of editing commands, one per line, of the following
form:

[address[,address]]function[arguments ]

In normal operation, sed cyclically copies a line of input into a
pattern space (unless there is something left after a D command),
applies in sequence all commands whose addresses select that pattern
space, and at the end of the script copies the pattern space to the
standard output (except under -n) and deletes the pattern space.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0