Super User Asked by Herdsman on October 3, 2020
I know in linux, I can just write command -a -b - "arg1" "arg2"...
, where single hyphen is "option/switch" separator. But how can I do similar in windows cmd?
I would like to see only particular option/switch from help:
c:> setx /? | findstr /r '/m'
, where the /m
switch I want to find. but the findstr
uses it as another switch:
FINDSTR: Bad command line
.
How to achieve that?
/m
switchI'm using:
setx /? | findstr /r '/m'
You do not need the /r
switch (which specifies a regular expression) as '/m'
is
not a regular expression.
You are using the wrong kind of quotes (single '
instead of "
), it should be "/m"
setx /?
outputs /M
so you either need to use /I
(ignore case) or "/M"
The /
in "/m"
needs to be escaped (using ), ie
"/m"
, if you are not using the /C:
(Use string as a literal search string) option
The following commands all do what you want:
setx /? | findstr "/M"
setx /? | findstr /c:"/M"
setx /? | findstr /i "/m"
setx /? | findstr /i /c:"/m"
Example output:
F:test>setx /? | findstr "/M"
SETX [/S system [/U [domain]user [/P [password]]]] var value [/M]
SETX [/S system [/U [domain]user [/P [password]]]] var /K regpath [/M]
/F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]
/M Specifies that the variable should be set in
SETX MACHINE "COMPAQ COMPUTER" /M
NTCurrentVersionCurrentBuildNumber" /M
CurrentVersionCurrentBuildNumber" /M
F:test>setx /? | findstr /c:"/M"
SETX [/S system [/U [domain]user [/P [password]]]] var value [/M]
SETX [/S system [/U [domain]user [/P [password]]]] var /K regpath [/M]
/F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]
/M Specifies that the variable should be set in
SETX MACHINE "COMPAQ COMPUTER" /M
NTCurrentVersionCurrentBuildNumber" /M
CurrentVersionCurrentBuildNumber" /M
F:test>setx /? | findstr /i "/m"
SETX [/S system [/U [domain]user [/P [password]]]] var value [/M]
SETX [/S system [/U [domain]user [/P [password]]]] var /K regpath [/M]
/F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]
/M Specifies that the variable should be set in
SETX MACHINE "COMPAQ COMPUTER" /M
NTCurrentVersionCurrentBuildNumber" /M
CurrentVersionCurrentBuildNumber" /M
F:test>setx /? | findstr /i /c:"/m"
SETX [/S system [/U [domain]user [/P [password]]]] var value [/M]
SETX [/S system [/U [domain]user [/P [password]]]] var /K regpath [/M]
/F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]
/M Specifies that the variable should be set in
SETX MACHINE "COMPAQ COMPUTER" /M
NTCurrentVersionCurrentBuildNumber" /M
CurrentVersionCurrentBuildNumber" /M
F:test>
Correct answer by DavidPostill on October 3, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP