So gives that trailing backslash message under the same circumstances as the linux one $ echo a\\b | grep \\Īnd escapes backslashes fine and has no problem with the literal quote at the end. Note that if I run this from cygwin, I don't get any error about trailing backslash $ echo a\"b | grep \"įrom cygwin it behaves a lot like the linux one So why, when I give the windows implementation of grep, something that doesn't end in a backslah, it'd give the error about a trailing backslash? # echo a\\b | grep \\Īs soon as I stick a literal quote on the end, no error # echo a\\b | grep \\\" # echo a\\b | grep \\\\Īnd the trailing backslash in linux, means there's a backslash on the end that has special meaning, because it's not escaped, and it's not doing anything. Then grep takes the two and turns it to one literal backslash. 'cos the shell goes for the four turns them to two. I can see that to find a single backslash in linux, I need four. I can get an error about a trailing backslash on linux, but not with a quote at the end. I can't see how to produce an equivalent "trailing backslash" error with grep on linux. The windows implementation of grep, gives an error about trailing backslash, when looking for just a quote. So for some reason, I don't understand why. So if I do C:\>echo a^"b | grep \^" <- a space after that quote. The above is looking for a quote followed by a space. If I put a space after that quote at the end then it doesn't give an error. This gives an error about trailing backslash C:\>echo a^"b| grep \^"Īnd this is related to that and also strange and I don't see why it's happening Now looking at linux echo echo ab\"c| grep echo ab\"c| grep \" echo a | grep \^"Ĭ:\>echo a | grep \^" echo a^"b | grep ^" I see and know that this works C:\>echo a^"b | grep ^" There is NO WARRANTY, to the extent permitted by law. In a Windows PowerShell the alternative for grep is the Select-String command. The findstr command is a Windows grep equivalent in a Windows command-line prompt (CMD). This is free software: you are free to change and redistribute it. Posted on Jby admin The grep command in Linux is widely used for parsing files and searching for useful data in the outputs of different commands. License GPLv3+: GNU GPL version 3 or later. Why would the windows implementation of grep command here, and from cmd, give an error message of trailing backslash? C:\Users\User>where grepĬ:\Users\User>c:\cygwin\bin\grep.exe -versionĬopyright (C) 2021 Free Software Foundation, Inc.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |