Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

best way to copy rest of file after a CRLFCRLF is found

Apr
1,794
15
What is the best way to copy the rest of a file after a CRLFCRLF is found?
 
Here's one way. I don't know if it's the best way.

FFIND with /L will tell you where CRLFCRLF is. TAIL with /n+M will output the remainder of the file; redirect it.

Code:
v:\> type file1.txt
aaaaa
bbbbb
ccccc

ddddd
eeeee

fffff
ggggg

v:\> ffind /k /m /l /t"^r^n^r^n" file1.txt
[4]

v:\> tail /n+4 file1.txt > file2.txt

v:\> type file2.txt
ddddd
eeeee

fffff
ggggg

v:\>
 
I don't quite understand how that works (below). Maybe I'm not looking at it in the right way.

FFIND numbers lines starting at 1. The "^r^n^r^n" is in there, but the first half of it is at the end of line 3 and the second half is on line 4. I don't know why it's found at all and why FFIND reports line 4 (and I'm not complaining about either behavior).

Code:
v:\> type file1.txt
aaaaa
bbbbb
ccccc

ddddd
eeeee

fffff
ggggg

v:\> ffind /k /m /l /t"^r^n^r^n" file1.txt
[4]

Here's an alternative to what I did in post #2 ... use a regular expression to find an empty line. That one makes sense to me.

Code:
v:\> ffind /k /m /l /e"^$" file1.txt
[4]
 
v:\> ffind /k /m /l /t"^r^n^r^n" file1.txt
[4]

v:\> tail /n+4 file1.txt > file2.txt

v:\>[/code]
How strip all non-numeric chars from the ffind result - assuming you do:

set nLocation=%@execstr[ffind /k /m /l /t"^r^n^r^n" file1.txt]

nLocation would eq "[4]" .....

Also @vefatica - we are a bit of a small world. My favorite barber is from upstate NY. not sure what town or how close to Syrcause NY he grew up at.... I'll reach out to him and let you know....
 
This ought to do it.

Code:
set nLineNumber=%@strip[[],%nLocation]

Yeah, let me know about your barber. I'm in Syracuse now but grew up in a little village called Ravena near Albany, NY.
 
@vefatica - met my old barber for lunch today and he is form Birhamtom NY..... - do you konw that area?
 
@vefatica - met my old barber for lunch today and he is form Birhamtom NY..... - do you konw that area?
Did you mean Binghamton? Not really. It's about 70 miles south of me. I go to a restaurant there (Cortese's) once in a while and always have trouble finding the place.
 
Did you mean Binghamton? Not really. It's about 70 miles south of me. I go to a restaurant there (Cortese's) once in a while and always have trouble finding the place.
I guess that is where - sorry for the typos....
 
Did you mean Binghamton? Not really. It's about 70 miles south of me. I go to a restaurant there (Cortese's) once in a while and always have trouble finding the place.
I guess Cortese Restaurant is it? Most of the items loook great to me. if I ever make up to your part of the woods - maybe we could do dinner - LOL
 

Similar threads

Replies
7
Views
2K
Back
Top