Subject:
|
Re: TXT-file question
|
Newsgroups:
|
lugnet.off-topic.geek
|
Date:
|
Wed, 18 Dec 2002 20:50:50 GMT
|
Viewed:
|
568 times
|
| |
| |
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'.
:)
Dan
|
|
Message has 1 Reply: | | 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)
|
Message is in Reply To:
| | Re: TXT-file question
|
| (...) Are you on windows? (if so I don't know) or on UNIX/linux? If you're on UNIX or linus you could use sed. 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 (...) (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
|
|
|
|