njau-sri / hpc

MIT License
1 stars 3 forks source link

Linux #4

Open hjbreg opened 5 years ago

hjbreg commented 5 years ago

Count number of lines (.fq.gz)

for e in $(ls *.fq.gz)
do
    n=$(gunzip -c $e | wc -l)
    echo $e $n
done
hjbreg commented 5 years ago

sed

Convert line ending DOS (\r\n) to UNIX (\n)

sed -i 's/\r$//' input.txt

Replace between WHITESPACE, TAB, COMMA

sed -i 's/ /,/g' input.txt
sed -i 's/,/\t/g' input.txt
sed -i 's/\t/ /g' input.txt
hjbreg commented 5 years ago

awk

Filtering keep first line

awk 'NR==1 || /pattern/' input.txt

Output column

awk 'NR==1 {print $1,$2}' input.txt

Split string

awk 'NR!=1 {split($1,a,"_"); print a[1],a[2]}' input.txt

Print with TAB

awk '{print $1 "\t" $2}' input.txt

Filtering numbers

awk '$2<0.01' input.txt > output.txt

Substr

awk '$1=substr($1,3,2)'