zimxavier wrote:I need to extract all lines from the first to the 1500th. I use
\inc option but it doesn't work. (ERROR: invalid option)
Code: Select all
call JREPL ".*" "$0" /jmatch /INC: "1:1500" /f file.txt /o -
Oops
- There is a documentation error in the examples. The /INC and /EXC options should not have a trailing colon. I will release v6.7 to fix the docs.
Your regex is wrong because it will match and preserve the entire line, and then .* will also match the end of line, resulting in a blank line after every matched line. That can be fixed by using "^.*" to match only from the beginning of the line.
Also, the /JMATCHQ option is faster than /JMATCH
Code: Select all
call JREPL "^.*" "$txt=$0" /jmatchq /inc "1:1500" /f file.txt /o -
There is a simpler solution using the /K option to keep lines that have at least one regex match. The 0 after /K means do not include any additional lines before or after a match.
Code: Select all
call JREPL "^" "" /k 0 /inc "1:1500" /f file.txt /o -
zimxavier wrote:I use this code for updating some lines:
Code: Select all
@echo off
for /f "delims=" %%a in ('dir /b /a-d "DATA\*.txt" ') do (
call JREPL "VARIABLE_ALL_CULTURES: .*$" "stdin.AtEndOfStream?$0:stdin.ReadLine()" /j /f "DATA\%%~a" <"TEMP\all_cultures.txt" /o -
)
I would like to test the new version with
jq. What should be the new code ?
Couldn't be much simpler
Code: Select all
call JREPL "VARIABLE_ALL_CULTURES: .*$" "$txt=stdin.AtEndOfStream?$0:stdin.ReadLine()" /jq /f "DATA\%%~a" <"TEMP\all_cultures.txt" /o -
Dave Benham