Search code examples
grepclearcasefindstr

command similar to grep, in windows


I got the command findstr

cleartool lshistory -fmt "%n,%c" |findstr /C:"US-100"

which giving me the logs below

App.java@@\main\6,US-100
target@@\main\0,target@@\main,target@@,US-1001
target@@\main\1,US-1001
newfilecreated.txt@@\main\1,US-1001
newfilecreated.txt@@\main\0,newfilecreated.txt@@\main,newfilecreated.txt@@,US-1001
anotherfile.txt@@\main\1,US-1001
anotherfile.txt@@\main\0,anotherfile.txt@@\main,anotherfile.txt@@,US-1001
akshay.txt@@\main\1,US-1001
akshay.txt@@\main\0,akshay.txt@@\main,akshay.txt@@,US-1001

which is giving me the logs having comments US-1001 also but I want the logs specifically which has comment equals US-100 only not US-1001 logs


Solution

  • Looking at findstr, you could use a regexp

    cleartool lshistory -fmt "%n,%c" |findstr /R "US-100$"
    # or
    cleartool lshistory -fmt "%n,%c" |findstr /R ".*US-100$"
    

    The '$' anchor forces the line to ends with US-100.