To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 4105
4104  |  4106
Subject: 
Re: TXT-file question
Newsgroups: 
lugnet.off-topic.geek
Date: 
Wed, 18 Dec 2002 20:59:36 GMT
Viewed: 
503 times
  
In lugnet.off-topic.geek, Dan Boger writes:
In lugnet.off-topic.geek, Kyle McDonald writes:
Somethign like: (this is untested so YMMV)

for FILE in *.txt; do
  if sed 's/ABCD/WXYZ/g' < $FILE >$FILE.new; then
    mv $FILE.new $FILE
  else
    echo Pattern not found or other error in $FILE.
    rm $FILE.new
  fi
done

If you hav Cygnus installed on your windows machine that might
work also.

or, if you have perl (windows or unix), you can do this:

perl -i.bak -p -e 's/ABCS/WXYZ/g' *.txt

which will create a backup (file.txt.bak) before changing all 'ABCD' to 'WXYZ'.

  I'm on a pretty straightforward XP 98 system, alas.  Maybe I should just
pay some neighborhood kids to do it for me...
  Thank you for the input, though.

     Dave!



Message has 3 Replies:
  Re: TXT-file question
 
(...) try textpad (IMO the best text editor for the win-systems). you can download a version at www.textpad.com. there is a feature in the find-replace dialog where you can replace text in mulitple files at once. -chris (22 years ago, 18-Dec-02, to lugnet.off-topic.geek)
  Re: TXT-file question
 
(...) There may be some batch commands you can use, but I'm not sure offhand-- I used to be somewhat of a whiz with Windows NT batch (1), but it's been a while... not to mention that I know Windows 95/98 didn't have the same functionality for "for" (...) (22 years ago, 18-Dec-02, to lugnet.off-topic.geek)
  Re: TXT-file question
 
(...) Or get PERL for Windows (URL) (22 years ago, 18-Dec-02, to lugnet.off-topic.geek)

Message is in Reply To:
  Re: TXT-file question
 
(...) or, if you have perl (windows or unix), you can do this: perl -i.bak -p -e 's/ABCS/WXYZ/g' *.txt which will create a backup (file.txt.bak) before changing all 'ABCD' to 'WXYZ'. :) Dan (22 years ago, 18-Dec-02, to lugnet.off-topic.geek)

13 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR