1

I am using the CloudFoundry CLI tool to tail logs from a remote cloudfoundry server. As per the cloud foundry log docs the command is

cf logs **app_name** --recent | grep RTR.

When i run this i get the error, grep is not recognized as a command. I believe this only works in a Unix based system. How can i use a grep like functionality from Windows CF CLI?

zb226
  • 9,586
  • 6
  • 49
  • 79
Tatha
  • 1,253
  • 2
  • 24
  • 42
  • possible duplicate of [What are good grep tools for Windows?](http://stackoverflow.com/questions/87350/what-are-good-grep-tools-for-windows) – Pradheep Jun 25 '15 at 16:38

3 Answers3

1
cf logs app_name --recent | findstr RTR

Findstr is capable of finding the exact text you are looking for in any ASCII file or files. However, sometimes you have only part of the information that you want to match, or you want to find a wider range of information. In such cases, findstr has the powerful capability to search for patterns of text using regular expressions.

Microsoft Technet

other solution would be that you install GNU grep on Windows. There are several ports available.

Sybil
  • 2,503
  • 3
  • 25
  • 36
  • Thanks @fyodor78 . findstr didnt give an error but the search results are not accurate as say grep. – Tatha Jul 08 '15 at 19:14
1

The Windows command prompt does not natively support bash prior to Windows 10, which is required for commands like grep. To use grep, you either have to use the git-bash shell provided during a git install, or in current releases of Windows, use the bash command in a Windows Command Prompt after installing the Windows Linux Subsystem. Windows Reference Documentation here

Bob Dill
  • 1,000
  • 5
  • 13
0

Perhaps you can use the git-bash if you have git installed on your machine. The git-bash comes with UNIX tools such as grep, so you would just open the git-bash instead of the Windows console and enter your command there.

J.P.
  • 155
  • 1
  • 8