2020-08-23

sed 使用单引号引用外部变量
(rna) bioinfor312@bioinfor312-OptiPlex-9020:~/桌面/dgf/aa/1_ontad_tf_sort$ cat nzero|grep “chr i − i- ij” | sed ‘s/./ou/chr’ i ′ − ′ i'-' ij’/chr’ i ′ − ′ i'-' ij’//g’ >1-1.result.txt
(rna) bioinfor312@bioinfor312-OptiPlex-9020:~/桌面/dgf/aa/1_ontad_tf_sort$ cat nzero|grep “chr i − i- ij” | sed ‘s/./ou/chr’ i ′ − ′ i'-' ij’/chr’ i ′ − ′ i'-' ij’
//g’
(rna) bioinfor312@bioinfor312-OptiPlex-9020:~/桌面/dgf/aa/1_ontad_tf_sort$ cat nzero|grep “chr i − i- ij” | sed ‘s/./ou/chr’ i ′ − ′ i'-' ij’/chr’ i ′ − ′ i'-' ij’//g’ >1-2.result.txt
(rna) bioinfor312@bioinfor312-OptiPlex-9020:~/桌面/dgf/aa/1_ontad_tf_sort$ j=1
(rna) bioinfor312@bioinfor312-OptiPlex-9020:~/桌面/dgf/aa/1_ontad_tf_sort$ cat nzero|grep “chr i − i- ij” | sed ‘s/./ou/chr’ i ′ − ′ i'-' ij’/chr’ i ′ − ′ i'-' ij’
//g’ >1-1.result.txt

cat *.result.txt | awk ‘{print $2}’

cat *.result.txt | awk ‘{print $2}’ | sort | uniq
cat *.result.txt | awk ‘{print $2}’ | sort | uniq -c

筛选共同的行列:
只选表1的值
cat *.result.txt | awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲' | sort | uni…line ‘$2==V1{print $1}’ `; echo l i n e , line, line,num1_1; done

选表1和2的值
cat *.result.txt | awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲' | sort | uni…line ‘$2V1{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 1}̲' `;num1_2=`cat…line '$2V1{print $1}’ `;echo l i n e , line, line,num1_1,$num1_2; done

值的计算

cat *.result.txt | awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲' | sort | uni…line '$2V1{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 1}̲' `;num1_2=`cat…line '$2V1{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 1}̲' `;xiaoshu=`ec…num1_1/$num1_2"| bc` ;echo -e KaTeX parse error: Undefined control sequence: \t at position 6: line"\̲t̲"xiaoshu; done

cat *.result.txt | awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲' | sort | uni…line ‘$2V1{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 1}̲' `;num1_2=`cat…line '$2V1{print $1}’ `;echo l i n e ; e c h o " s c a l e = 4 ; line;echo "scale=4; line;echo"scale=4;num1_1/$num1_2"| bc ; done

另外一种方法:
cat nzero | while read line ; do num=echo $line | awk '{print $1}'; name=echo $line | awk -F"_" '{print $2"_"$3}';echo -e KaTeX parse error: Undefined control sequence: \t at position 5: num"\̲t̲"name; done

在sed命令中使用外部变量有两种方式:

(1)sed命令使用双引号而不是单引号

例:var=cat

    echo "It is a dog" | sed "s/dog/$var/g"

(2)sed命令依然使用单引号,但将外部变量用单引号括起来

例:var=cat

    echo "It is a dog" | sed 's/dog/'$var'/g'

for i in X Y
do

for j in 1 2
do
cat nzero|grep “chr i − i- ij” | sed ‘s/./ou/chr’ i ′ − ′ i'-' ij’/chr’ i ′ − ′ i'-' ij’_//g’ |awk 'BEGIN{FS=" “;OFS=”\t"}{$1=$1;printKaTeX parse error: Expected 'EOF', got '}' at position 2: 0}̲' > chri-$j
done
done

for i in {1…18}
do
for j in 1 2
do
cat nzero|grep “chr i − i- ij” | sed ‘s/./ou/chr’ i ′ − ′ i'-' ij’/chr’ i ′ − ′ i'-' ij’_//g’ |awk 'BEGIN{FS=" “;OFS=”\t"}{$1=$1;printKaTeX parse error: Expected 'EOF', got '}' at position 2: 0}̲' > chri-$j
done
done

你可能感兴趣的:(Linux)