string - 在 CMD 中添加空格以选择字符串时加入行不起作用
问题描述
我的测试字符串是:
this is a sentence.
google.com
here is another sentence.
microsoft.com
this sentence has no period
我的代码是:
@echo off
setlocal EnableDelayedExpansion
set row=
@((For /F "EOL=|Delims=" %%# In ('^""%__AppDir__%find.exe" "."^<"%UserProfile%\i.txt"^"')Do @Set /P "=%%# "<NUL)&Echo()>"%UserProfile%\o.txt"
echo %row% >%userprofile%\o.txt
echo %row%
C:\Users\qwerp>joint3
ECHO is off.
我期待得到:
google.com microsoft.com
相反,我得到了:
ECHO is off.
解决方案
鉴于您的示例文件内容更改和声明的意图,这可能足以满足您的需求,只需更改find.exe
为findstr.exe
, (使用适当的选项):
@((For /F "EOL=|Delims=" %%# In ('^""%__AppDir__%findstr.exe" "\." "%UserProfile%\i.txt"^|"%__AppDir__%findstr.exe" "[^\.]$"^"')Do @Set /P "=%%# "<NUL)&Echo()>"%UserProfile%\o.txt"
推荐阅读
- python - 为什么我的 csv 包含的格式与我的脚本不同
- dart - 单例在 Dart 中是如何工作的?
- android - 忽略一些更新 android studio
- three.js - Three.js Vector.angleTo:如何同时获得更大的价值
- java - 如何使用原始代码在java中使用mysql-connector-java-8.0.20.jar
- python - UnboundLocalError:分配前引用的局部变量“infile”
- c - Makefile 的输出说明
- mongodb - MONGO DB UpdateOne WriteError
- android-studio - JetBrains Mono 字体未显示在我的字体文件中的 Android Sudio 项目中
- node.js - 在 NodeJS 和 React/Webpack 之间重用代码的最佳方式是什么?