I am looking for a one liner for this if it is possible.I have a sequence like thisCCGGTCTCTTCCGGTTCTGTCTTTTCGCTGGI want to get the output where I scan the sequence base by base and then take 20 bp from that. SO the output should be something like thisCCGGTCTCTTCCGGTTCTGTCGGTCTCTTCCGGTTCTGTCGGTCTCTTCCGGTTCTGTCTand so on..The length should always be 20 bpI wrote a perl code and it worked. Looking for one liner if some one can help using awk or sed??while(<>){    chomp;    for my $i(0..length($_)){        my $str = substr($_,$i,20);        next if(length($str) < 20);        print $str,\n;    }}Let me know
scanning a sequence and outputting a sub sequence
text processing
If you're already familiar with Perl, why not use it? Perl excels at one-liners:$ perl -F'' -lane 'for($i=0;$i<=$#F-20;$i++){print @F[$i..$i+20]}' fileCCGGTCTCTTCCGGTTCTGTCCGGTCTCTTCCGGTTCTGTCTGGTCTCTTCCGGTTCTGTCTTGTCTCTTCCGGTTCTGTCTTTTCTCTTCCGGTTCTGTCTTTTCTCTTCCGGTTCTGTCTTTTCTCTTCCGGTTCTGTCTTTTCGCTTCCGGTTCTGTCTTTTCGCTTCCGGTTCTGTCTTTTCGCTTCCGGTTCTGTCTTTTCGCTGCCGGTTCTGTCTTTTCGCTGGExplanationThe -a switch makes perl act like awk, splitting its input lines on the value given by -F and saving them in @F. Since -F here is empty, the result is that the @F array's elements are the characters of the line.  The -l switch turns on chomp automatically and also adds a \n to each print call. The script itself simply increments a counter ($i) from 0 until the length of the array ($#F) and does so as long as $i is less than or equal to the array's length minus 20, to only get sequences of the right size. It then prints the array slice from the current value of $i until $i+20. If you run this with -MO=Deparse to analyze what its doing, you can see that it runs:$ perl -MO=Deparse -F'' -lane 'for($i=0;$i<=$#F-20;$i++){print @F[$i..$i+20]}' fileBEGIN { $/ = \n; $\ = \n; }LINE: while (defined($_ = <ARGV>)) {    chomp $_;    our @F = split(//, $_, 0);    for ($i = 0; $i <= $#F - 20; ++$i) {        print @F[$i .. $i + 20];    }}-e syntax OK