bash 스크립트에서 개별 플래그로 각 플래그에 주석을 추가하려면 어떻게합니까? -i do not put an indel within

가능한 한 자기 문서적인 bash 스크립트를 작성하고 싶습니다.

많은 플래그가있는 소프트웨어를 실행할 때 명령을 여러 줄로 나누고 각 줄의 끝에 주석을 추가하여 플래그가 무엇을하는지 알려줍니다 (man 페이지의 정보). :

bwa aln \
-n $n \ # -n max #diff (integer) or missing prob under 0.02 err rate (float) [0.04]
-o $o \ # -o maximum number or fraction of gap opens [1]
-e $e \ # -e maximum number of gap extensions, -1 for disabling long gaps [-1]
-i $i \ # -i do not put an indel within integer bp towards the ends [5]
-d $d \ # -d maximum occurrences for extending a long deletion [10]
-l $l \ # -l seed length [32]
-k $k \ # -k maximum differences in the seed [2]
-m $m \ # -m maximum entries in the queue [2000000]
-t $t \ # -t number of threads [1]
-M $M \ # -M mismatch penalty [3]
-O $O \ # -O gap open penalty [11]
-E $E \ # -E gap extension penalty [4]
-R $R \ # -R stop searching when there are >integer equally best hits [30]
-q $q \ # -q quality threshold for read trimming down to 35bp [0]
-f $f \ # -f file to write output to instead of stdout
-B $B \ # -B length of barcode
-L $L \ # -L log-scaled gap penalty for long deletions
-N $N \ # -N non-iterative mode: search for all n-difference hits (slooow)
-I $I \ # -I the input is in the Illumina 1.3+ FASTQ-like format
-b $b \ # -b the input read file is in the BAM format
-0 $0 \ # -0 use single-end reads only (effective with -b)
-1 $1 \ # -1 use the 1st read in a pair (effective with -b)
-2 $2 \ # -2 use the 2nd read in a pair (effective with -b)
-Y $Y \ # -Y filter Casava-filtered sequences
-prefix $prefix \ # -prefix Prefix
-inputfile $inputfile \ # -inputfile Input file (FastQ format)

문제는 \ 문자 다음에 아무것도 가질 수 없다는 것입니다 (bash에게 명령이 다음 줄에서 계속된다는 것을 알려주십시오). 의견.

아무도 이것을 할 수있는 방법이나 비슷한 것을 알고 있습니까?



답변

슬래시 전에 주석을 평가할 수 있으며 스크립트에 영향을 미치지 않는 주석에 대해 빈 문자열을 생성하면됩니다.

bwa aln \
-n $n `# -n max #diff (integer) or missing prob under 0.02 err rate (float) [0.04]` \
-o $o `# -o maximum number or fraction of gap opens [1]` \
....

답변

명령 전에 코드를 주석 처리하려면 여러 줄을 사용하는 것이 좋습니다. 처럼

 # this command uses multiple parameters
 # it requires 4 parameters and none are optional with no defaults
 # parameters used : 
 # -q              name of the file
 # -b              size to truncate
 # -n              new location
 # -r              recursive

답변

한 가지 옵션은 명령을 조각으로 구성하여 줄 연속에 대해 걱정할 필요가 없습니다.

cmd='date'                # run the date program
cmd=${cmd}' -d 20130905'  #  for this date
cmd=${cmd}' +%s'          #  with output in this format
echo $cmd                 # review the command
eval $cmd                 # run the command