Delete a specific string in a file at the command prompt

Delete a specific string in a file at the command prompt

To delete a specific string in a file at the command prompt, write

set removeMoji=aaa
set del=
setlocal enabledelayedexpansion
for /f "delims=" %%a in (a.txt) do (
  set line=%%a
  echo !line:%removeMoji%=%del%! >> a_after.txt
)
endlocal

We are for-ing a.txt one line at a time.

If there is a letter aaa, it is deleted and re-created in a_after.txt.

コメント

Discover more from 株式会社CONFRAGE ITソリューション事業部

Subscribe now to keep reading and get access to the full archive.

Continue reading

Copied title and URL