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 / 4107
4106  |  4108
Subject: 
Re: TXT-file question
Newsgroups: 
lugnet.off-topic.geek
Date: 
Wed, 18 Dec 2002 21:59:28 GMT
Viewed: 
517 times
  
In lugnet.off-topic.geek, Dave Schuler writes:
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.

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" statements, so chances are XP wouldn't work with it
either. Lemme poke around...

Hmm... looks like you might be able to jigger something in batch. But it may
not work on XP, and even if it does, it'd be annoying, and it would ONLY
work if the text you're looking to replace is the entire contents of a
particular line.

Oh my. I just started to try and write it. Wow it's annoying. Suffice to say
if you were a programmer, it'll STILL be a challenge. There's so many stupid
tricks I forgot you have to do like output constantly to temporary files and
scan them for line numbers, and even to make subroutines, etc. Wow. I had
forgotten.

Anyway, you probably COULD throw a batch program together with the commands
for, findstr, find, more, if, goto, and echo. But it could easily be far
more trouble than it's worth.

DaveE

(1) - After being refused training (people in those departments didn't have
the time to train me), I was left to write programs with only help pages on
NT batch and an internet full of helpful examples. I ended up with a 50K+
batch program with clickable, dynamic menus, and lots of other wacky
advanced things that should NEVER have been done in NT batch code (this was
back in 1997 or so). But it was admittedly pretty cool.



Message has 1 Reply:
  Re: TXT-file question
 
<snip> (...) have (...) on (...) was (...) <snip> and <sigh> oh dear, yup those were the days, writing simple batch files and people calling you a programer. my computers were organized and navigated with batch files since 92 because windows was so (...) (22 years ago, 19-Dec-02, to lugnet.off-topic.geek)

Message is in Reply To:
  Re: TXT-file question
 
(...) 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! (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