I apologize for using code designation with my file contents but the formatting was being weird otherwise.
I have a 6,6494,940 line file that contains the following:
@MSQ-M01247R:81:000000000-ACWD8:1:1101:11811:1088 2:N:0:
CCCCCTCTTCCCTTTCTTCCCCCCTCTTTCTTCTTTCTCTTTTCTCCCTCTCCTTTTTTTCTCCTTTTTTTCCTTT
+
############################################################################
I want to write the first 10 characters of each line to a new file in order:
@MSQ-M0124
CCCCCTCTTC
+
##########
I used the following bash script:
while read line
do
long=$line
short=${long:0:10}
echo ${short}
done < $1
With the following command:
./bashscript.sh fileread.fastq >> filewrite.fastq
Something went wrong. My new/write file had 628,429,568 but it should have had 66,494,940 like the original/read file. So it looks like it kept looping.
When I use the head command on the new/write file I get:
@MSQ-M0124
CCCCCTCTTC
+
##########
@MSQ-M0124
CCTCCTCCTT
+
##########
@MSQ-M0124
CCTTCTTCTT
When I use the tail command I get:
CCCCCGGGGG
+
CCCCCGGGGG
GAGTCGTCTG
+
CCCCCGGGGG
+
CCCCCGGGGG
GAGTCGTCTG
+
CCCCCGGGGG
+
CCCCCGGGGG
GAGTCGTCTG
+
cut
is your friend!
$ cut -c-10 file
@MSQ-M0124
CCCCCTCTTC
+
##########
This uses cut
with the option -c
, from characters, to get the range -10
, which implicitly means from the 1st to the 10th.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다