写的比较详细的一个Linux下引号的区别,Mark一下。

http://www.opsers.org/linux-home/base/shell-in-single-quotes-double-quotes-backticks-use-a-backslash.html

顺便加上自己写的一个小程序,做个示例。

 1 #! /bin/bash -
2
3 #@Author: Liang Feng
4 #@Create Time: 2011-11-26
5 #@Function: cut qrels into different levels, i.e. 0, 1, 2
6 ## 1 means relevance, 2 means high relevance
7
8 root_dir="/home/liangfeng/Project/TREC2011/Utility/qrel"
9 allrel_dir="$root_dir/allrel"
10 highrel_dir="$root_dir/highrel"
11 zerorel_dir="$root_dir/zerorel"
12 qrel_file="$root_dir/microblog11-qrels"
13
14 counter=1
15 while [ $counter -le 50 ]
16 do
17 all_output_file="$allrel_dir/$counter.ans"
18 high_output_file="$highrel_dir/$counter.ans"
19 zero_output_file="$zerorel_dir/$counter.ans"
20 awk '($1=='"$counter)"' && ($4 == 0) {print $3}' $qrel_file | sort -r > $zero_output_file
21 awk '($1=='"$counter)"' && ($4 == 1) {print $3}' $qrel_file | sort -r > $all_output_file
22 awk '($1=='"$counter)"' && ($4 == 2) {print $3}' $qrel_file | sort -r > $high_output_file
23 counter=`expr $counter + 1`
24 done