简体   繁体   中英

How to replace the string in the file through command line in the most simple way?

Suppose the file 'file', in which there is the string

  c:\home users\XXX\

How to replace this string into

  d:\street users\YYY\ ?

PS The question holds after my failure with fart, see here .

set /p "d:\street users\YYY\"<nul >test.txt
dir /b  c:\home users\XXX\file >>test.txt

Explanation: First line creates a file that does not end with a new line. Second line appends a "BARE" listing of file. Hence:

type test.txt

should give you

d:\street users\YYY\file

If you want to execute a command then instead of a text file create a batch file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM