Hi everyone I have this code:
-----------------------------------------------------
$ linetoselect sasa
asdlaldsalda
ld
als
alds
lda
lds
l
linetoselect sasa
akdskadkskdsadk
askdskdak
ksadkakd
adkpskdak
aksds
$ linetoselect
sdsad
sda
sdad
adsa
linetoselect ssa
sda
kksk
kkk
awda
-----------------------------------------------------
I would write a batch code doing the following step
If the first character of (Findstr /n /c: linetoselect ) = "$" else >> file.txt
At the end of the code I would have a file.txt where only linetoselect not starting with $ are reported
Could anyone help me?
If findstr first charatcter
Moderator: DosItHelp
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: If findstr first charatcter
As long as linetoselect lines won't contain $ anywhere other than the start of the line, you can search for linetoselect and then pipe that to a second findstr that finds lines that don't contain $
Note that I've assumed the data is in a file called raw_data.txt.
Code: Select all
findstr /n /c:"linetoselect" raw_data.txt | findstr /v /c:"$" >>file.txt
Re: If findstr first charatcter
Thanks a lot for your help it works and in order to consider only $ at the beginning of the line it needs add /b.
Thanks a lot. Best regards
Thanks a lot. Best regards