how do I replace a word in a file using DOS commands??


 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions how do I replace a word in a file using DOS commands??
# 1  
Old 04-24-2008
how do I replace a word in a file using DOS commands??

how do I replace a word in a file using DOS commands??
# 2  
Old 05-22-2008
Just go into the editor (edit.com) and change whatever. I have never seen any version of DOS (except maybe the really old ones) that do not have EDIT.COM among all the normal files like the command interpreter. From what I am aware there isn't an actual command besides edit.com that will do any kind of file editing of that sort in DOS or Windows.

To use EDIT.COM in DOS

1) Go to the directory with EDIT.COM in it (usually in the root of the C: drive or in C:\DOS\ or some similar directory)

2) Type "EDIT $FILEPATH" (excluding the quotation marks of course), where $FILEPATH is the path to the file you wish to edit (example: "EDIT A:\HOMEWORK.TXT" excluding the quotes)

3) In the MS-DOS Editor, navigate to the word you wish to replace, highlight it, and type a new word in. Then, click on File > Save and then File > Exit (or, if you don't have a mouse, use Alt + S then Alt + X)

4) Your file is now edited.

Note that this does not work for formatted documents (.rtf, .doc, etc.) and I don't know if this works for documents created with VIM or other UNIX editors; if it's plain text, this method will work.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace a word based upon the file content

I have a file which contains timestamp and date in the second column. If the line contains one of the word then it need to be replace like below. Any help is appreciated. File: a smallint b timestamp c date d varchar O/P: a smallint ... (1 Reply)
Discussion started by: JoshvaPeter
1 Replies

2. UNIX for Advanced & Expert Users

Perl command to replace word in file...

Hi, I want to search for a specific word in file and replace whole line with new text. e.g. 1) I have file with below lines APP=ABCD 12/12/2012 DB=DDB 01/01/2013 I need perl command which will check for APP=$VAL and replace whole line with APP=$NEWVAL $NEWDT Simlarly need a... (2 Replies)
Discussion started by: mgpatil31
2 Replies

3. Shell Programming and Scripting

Replace a word after a particular word in a file

Hi, I want to replace a word in a file which occurs after a particular word. For example : $cat file.txt CASE WHEN AND c1 = 'I' AND c2= '2' THEN 1 WHEN AND c1= 'I' AND c2= '0' THEN 2 So in this example i want to replace... (4 Replies)
Discussion started by: ashwin3086
4 Replies

4. Shell Programming and Scripting

Replace a word with string from another file

Hi, this belongs a little to my other post but only at the starting point. With find -name "*.htm*" i got a list like this: ./1999/01/file1.html ./1999/01/file2.html ./1999/02/file1.html ./2000/04/file1.html ./2000/04/file2.html ./2000/04/file3.html ./2000/file1.html... (2 Replies)
Discussion started by: Tonda
2 Replies

5. Shell Programming and Scripting

replace a word in a file only first 10 occurances

file.txt contains abc :-X 1234 :-X fjhfkf :-X ffwerw :-X fdfgetw :-X hwfhe89 :-X in the this file there are 6 occurance of -X i want to replace only first 3 occurances of '-X' with 'XY' and write back to same file. (4 Replies)
Discussion started by: nawazkhan77
4 Replies

6. UNIX for Dummies Questions & Answers

Replace word in a file

Guys, I need to replace a portion of the lines in the file depending on the word in my file i have this content use DBNAME go print "use DBNAME" i want to replace the variable DBNAME with something else. But the catch is this line is not always "use DBNAME". Sometimes it can be like "use... (3 Replies)
Discussion started by: sasiharitha
3 Replies

7. Shell Programming and Scripting

replace word in a file

there are 300 files in a directory , some of these files has a word "error" , I word to change this word to "message" , can advise what can i do ? thx. (5 Replies)
Discussion started by: ust
5 Replies

8. Shell Programming and Scripting

How to replace a word with a series of words in a file

Hi, I have a Template file 'TL.body' which says as follows: "There are no <FILENAME> files on the server. " The missing file names are identified and stored in a variable. For Eg: MISSFILE="abc.txt def.txt xyz.txt" I want the values of MISSFILE variable to be replaced against... (2 Replies)
Discussion started by: brap45
2 Replies

9. UNIX for Dummies Questions & Answers

?Using Unix commands in Microsoft (Windows') DOS Prompt?

I ran a search for "Unix Dos" in the search field box and checked a few pages' results but did not find what I was looking for. I am trying to find out if there are choices of applications that would enable using Unix commands inside a Windows environment, particularly the DOS Prompt. The only... (2 Replies)
Discussion started by: HLee1981
2 Replies

10. UNIX for Dummies Questions & Answers

Unix Equivalents to the following Dos Commands

cd... dir... rem ... type... del... copy... mkdir... rmdir... attrib... And how can I get this information? My email address is ***removed*** By way the 001 are numbers. (3 Replies)
Discussion started by: jaquar85
3 Replies
Login or Register to Ask a Question