I'm not familiar with Windows shell. So, let's say my file is like:
DontAppend this line shouldn't be appended
DontAppend this line shouldn't be either
Some lines
more lines
And I'm appending like this:
type file.txt >> AppendHere.txt
This appends the whole file. How do I make it so it skips lines that begin with "DontAppend"?
The command findstr will let you search for lines not containing a string or regular expression so you can use:
findstr /vrc:"^[^A-Za-z0-9]*DontAppend" file.txt >> AppendHere.txt
The /r option says it should use regular expressions and the caret (^) says it should begin with the string.
Edit: added a filter for non alphanumeric chars that may solve the Unicode issues (Unicode files sometimes have a non-printable indicator characters in the beginning).
Either get grep
for windows or you could use Windows' own find
command
type so.txt|find /v "DontAppend" >> output.txt
The /v
option means output lines that dont match your string.
find
works for very simple things like this but any more you will need a real filtering tool like grep