In a previous thread I have made an observation, but my implementation was not good.
Another trial: ---------- Post updated at 03:09 AM ---------- Previous update was at 02:50 AM ----------
Scru's last sample strips leading spaces with $(echo).
Nice alternatives are
Last edited by MadeInGermany; 07-21-2014 at 05:30 AM..
This User Gave Thanks to MadeInGermany For This Post:
Nice with the three times. It could also be written as -v h="$(wc -l file)" is a nicer alternative to remove the leading space (by awk , rather than shell), although there was no determinable difference in speed..
In testing (using the second result, with file in read cache):
or
Seems to be the fastest solution with 100001 lines..
The latter did not seem to work properly with BSD awk, since it produced 10,002 lines (an additional line due to an extra newline) and in mawk it produced mawk: program limit exceeded: maximum number of fields size=32767
With gawk though it worked really well though:
As is most often the case, mawk was fastest:
In fact when using mawk, it became less relevant, since it performed so fast that there was a negligible difference between the fastest solutions
gawk 4 (which uses some of the techniques of mawk) now also often performs better than gawk 3 and BSD awk..
I need to split the incoming source file in to multiple files using awk.
Split position is (6,13) : 8 positions
All the records that are greater than 20170101 and less than or equal to 20181231 should go in a split file with file name as source... (11 Replies)
HI Guys,
Can you please let me know the procedure to reestablish the SRDF which is half split, as you can see from the below O/P that one of the device is synchronized and other devices are in split mode
Source (R1) View Target (R2) View MODES... (2 Replies)
Im stumped on this one. Id like to echo into a .txt file all names for an xml feed in a huge folder. Can that be done?? Id need to echo <name>This name</name> in client.xml files.
$path="/mnt/windows/path"
echo 'recording names'
cd "$path"
for names in $path
than Im stuck on... (2 Replies)
Hi all,
I'm pretty new to Shell scripting and I need some help to split a source text file into multiple files. The source has a row with pattern where the file needs to be split, and the pattern row also contains the file name of the destination for that specific piece. Here is an example:
... (2 Replies)
Hi!
I have a file like this:
a,b,c,12,d,e
a,b,c,13,d,e
a,b,c,14,d,e
a,b,c,15,d,e
a,b,c,16,d,e
a,b,c,17,d,e
I need to split that file in two:
If field 4 is equal or higher than 14 that row goes to one file and if it is equal or higher than 15 to another.
Can anyone point me in the... (2 Replies)
I did a lot of search on this forum on spiting file; found a lot, but my requirement is a bit different, please guide.
Master file:
x:start:5
line1:23
line2:12
2:90
x:end:5
x:start:2
45:56
22:90
x:end:2
x:start:3
line1:23
line2:12
x:end:3
x:start:2
line5:23 (1 Reply)
I have gone through all the threads in the forum and tested out different things. I am trying to split a 3GB file into multiple files. Some files are even larger than this.
For example:
split -l 3000000 filename.txt
This is very slow and it splits the file with 3 million records in each... (10 Replies)
I am trying to read a file and split the file into multiple files. I need to create new files with different set of lines from the original file. ie, the first output file may contain 10 lines and the second 100 lines and so on. The criteria is to get the lines between two lines starting with some... (8 Replies)