You are not logged in.
Pages: 1
Dealing with curl utility, trying to read about its parameters '-o' performing:
curl -h | findstr "-o"
FINDSTR: Bad command line
curl probably expect there is a (wrong) parameter doublequoted. Find two workarounds:
curl -h | findstr /C:"-o"
and
curl -h | findstr "\-o"
first question is: Is this known issue? Did not find it described.... Second question: which workaround is better?
Running W10.
Offline
An undocumented (although mentioned on https://ss64.com/nt/findstr.html) feature of findstr is that it takes options in both the traditional Windows style (/option) and the Unix style (-option). Since /O is a valid option, findstr is reading -o as the flag to print the character offset before each matching line, but then because it's being read in as an option, findstr incorrectly believes that no search string is being provided and throws that error.
Your first workaround is the preferred method, as /C should always be specified whenever possible.
Last edited by Shadow Thief (16 Apr 2020 06:38)
Offline
An undocumented (although mentioned on xxx feature of findstr is that it takes options in both the traditional Windows style (/option) and the Unix style (-option). Since /O is a valid option, findstr is reading -o as the flag to print the character offset before each matching line, but then because it's being read in as an option, findstr incorrectly believes that no search string is being provided and throws that error.
My question in "known issue" mean how findstr distinguish between paramater and pattern to search. Expect that the doublequoted string is treated a s pattern to search. Do findstr parse every string for possibly valid option and consider it is a pattern only if valid option does not found there?
Offline
I didn't find anything in https://stackoverflow.com/questions/884 … str-comman, but then I thought that this might be a feature of cmd.exe itself, so I read through https://stackoverflow.com/questions/409 … se-scripts. I believe the quotes get stripped during the tokenization part of phase 2 because they don't have any special meaning to findstr, unlike find, which requires quotes.
Offline
Comparing:
echo hallo world| findstr "hallo" "world"
FINDSTR: Cannot open world
echo hallo world| findstr hallo world
FINDSTR: Cannot open world
echo hallo world| findstr "hallo world"
hallo world
look like findstr eat first parameter as a pattern, than everything else is considered as a filenames. It does not support dash as a identificator the datasource come from stdin instead of file, as many other programs.
Offline
Findstr takes arguments in the order
findstr flags search_string file_name
, so in your first two examples there, you are only providing "hello" as the search string and since world is being passed in as the thing to search, the pipe is ignored.
Offline
Pages: 1