This does it
@echo off
setlocal enableextensions enabledelayedexpansion
set /p num=Enter chars to show between quotes:
set /a num=%num%+1
for /f "delims=" %%f in (a.txt) do (
set a=%%f
echo !a:~0,%num%!^"
)
So, using your example, that's in a.txt
So each line starts with a quote, and there are spaces too though it works if there aren't spaces as well.
"hey what is going on @mike220. I am working on your car. Its engine is in very bad condition"
"Because if you knew, you'd get shredded and do it with certainty"
"@honey220 Do you know someone who has busted their ass on a diet only for results to come to a screeching halt after a few weeks"
And running the batch script
C:\blah>a.bat
Enter chars to show between quotes: 3
"hey"
"Bec"
"@ho"
C:\blah>a.bat
Enter chars to show between quotes: 50
"hey what is going on @mike220. I am working on you"
"Because if you knew, you'd get shredded and do it "
"@honey220 Do you know someone who has busted their"
C:\blah>
I have now added two lines, to make it output to a file def.txt
@echo off
setlocal enableextensions enabledelayedexpansion
del def.txt 2>nul
set /p num=Enter chars to show between quotes:
set /a num=%num%+1
for /f "delims=" %%f in (a.txt) do (
set a=%%f
echo !a:~0,%num%!^"
echo !a:~0,%num%!^" >>def.txt
)
C:\crp\dlsnex>a
Enter chars to show between quotes: 2
"he"
"Be"
"@h"
C:\crp\dlsnex>type def.txt
"he"
"Be"
"@h"
C:\crp\dlsnex>
for
statements in cmd are a bit tricky. To understand this one, just start off trying to write a for statement that prints every line of a file, without trimming, and use a simple file like one with two lines abcdefg and hijklmn. Then this for statement for /f %f in (a.txt) do @echo %f
then you build it up. But that is where you start, if you are to figure out how to do it. Once you have that, add the "delims=" see what effect it has(you might need some spaces in the lines of the file, to see the effect). Then look at how you can get a substring in batch. set a=abcdefg echo %a:~0,2% (prints ab).
The best tool to manage huge txt wordlist for Windows is:
Unified List Manager (ULM)
ULM
You can sort, merge, split, remove duplicates and many other useful stuff.
Best Answer
header.txt
.split --lines=100 data.txt
(this generate lots of files with 100 lines in them each named xaa xab xac and so on)for a in x??; do cat header.txt $a > $a.txt; done
This results in your finished data files (with headers) being calledxaa.txt xab.txt xac.txt ...
If the amount of data is so large (or you split on fewer lines) that xxx files is not enough split makes four letter named files. In that case insert an extra
?
in thefor
-statement above.Edit:
To automate the extraction of the header use
head -4 origdata.txt > header.txt
to extract the first four lines. Usetail -n +4 origdata.txt > data.txt
to extract everything except the first four lines. Now you have two files one with the header and one with the data. It should not be too hard to combine this to a script. (I have no access to bash today)