Tag Info

New answers tagged

1

busybox seq -s' word ' 4000 | sed '/000/w /dev/fd/2' | wc -l OUTPUT word 1000 word 2000 word 3000 word 4000 4000 You should just be able to use busybox's builtin seq and specify word as a separator. Then you can >redirect it to a file if you wish. In the above example I split out to sed just so you could get an idea of the output without having to ...


5

You can make a here document and use cat: $ cat <<EOT >output $a EOT $ wc -l output 40000 I don't know exactly how powerful your Busybox's ash is (it's configurable), but that should work anywhere, even with no builtins at all. It expands the variable value into a quasi-file, which is then given to cat, rather than putting the value itself into ...


4

Additional explanation based on NTFS filesystem performance After writing the lower section ot this answer, the OP pointed out that the script is running it on a NTFS disk, and suspects that may be part of the problem. This would not be too surprising: There are performance problems with NTFS speciffically related to handling many small files. And we ...


2

I'm curious to solve the memory problem with the split solution from the question, but independently, this alternative approach may be useful: You could use csplit instead of split to split this kind of file. For csplit, you need to define a pattern to define where to split, and you can use the lines with a single number as separator - if you know there ...


1

An awful perl: $ perl -anle ' printf "%s Apos(string)\n",$_ and next if /^#/; printf "%s",$_; $len = 12 - length((split(/\s+/,$_,3))[-1]); for $pos_ss (@F[2..$#F]) { $char = substr($F[1],int($pos_ss)-1,1); push @res, int($pos_ss) if $char eq 'A'; } printf "%@{[12-4+$len]}s\n", join ", ",@res; @res=(); ' file ...


1

How about the following awk script: #!/usr/bin/awk -f BEGIN { FS="\t" print "#key\tstring\tpos(string)\tApos(string)" } { out="" printf "%s\t",$0 split($2,str,"") gsub(/ /,"",$3) split($3,pos,",") for (i in pos){ if (str[pos[i]]=="A"){ out = out pos[i] ...


1

I'm not sure how you're doing it now (it would be helpful to see your Python code), but you can create a list of the elements of column 3 which point to an 'A' in column 2 like so: [i for i in COLUMN3 if COLUMN2[i]=='A'] This seems like a simple problem, but maybe I don't fully understand it. Perhaps you are forgetting that strings are iterables?



Top 50 recent answers are included