Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux中无法识别的命令错误_Linux_Bash - Fatal编程技术网

Linux中无法识别的命令错误

Linux中无法识别的命令错误,linux,bash,Linux,Bash,大家好 我曾经写过一个剧本,但突然间它不起作用了,我也不知道为什么。 这是我的剧本: #!/bin/bash #This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position. _pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt #hg-19 ref genome. genome_path="/

大家好
我曾经写过一个剧本,但突然间它不起作用了,我也不知道为什么。
这是我的剧本:

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done
当我运行它时,会出现以下错误:

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done
line 30:  : command not found
其中第30行是该行:

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done
tee $_pwd/filtered_fasta/$faOutput |\ 
我不知道为什么会发生此错误,它以前工作正常。
我真的希望有人能帮我解决这个问题

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done

更新:我删除了所有的“\”,现在一切正常。

如果我认为您粘贴的脚本正确,那么在反斜杠
\
后的第30行中有一个字符

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done
Bash本身正在告诉您未知命令的名称:

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done
line 30:  : command not found
之间的内容是Bash无法识别的命令名,这是一个空白

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done
按照注释中的建议,删除管道
\
后的反斜杠
\
,并确保管道字符是行中的最后一个字符。这将提高可读性

#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done

而且,好的编辑器可以显示空白()。启用它将显示此类错误。

FWIW,管道字符后的反斜杠是不必要的。只要管道字符是一条直线上的最后一个字符,外壳就知道使用下一条直线作为下一个管段。但是尝试运行您的脚本。您将获得许多改进的提示,这些改进可能使调试更容易。错误与以回车(
\r
)结尾的行一致。另请参见,(U&L.SE),(SO),(AskU)等。祝您好运。我没看到。:-)
#!/bin/bash
#This script gets damage seq bed files of 4 nucleotides and filters only those with dipyrimidins in 2-3 position.
_pwd=/cs/icore/elisheva.h/Damage_seq/Sheera_4nt
#hg-19 ref genome.
genome_path="/cs/icore/elisheva.h/hg19-ref_genome/genome/hg_19_ref_genome.fa" 
#Scans all the damage seq given bed files.
for bedFile in $_pwd/*.bed
do
  #Removes duplicates lines.
  sort -u -o $bedFile  $bedFile 
  #Sorts the files according to chromosome and coordinates. 
  sort -k1,1 -k2,2n -o $bedFile  $bedFile 
  name=`basename $bedFile`
  #Adjusts the fasta file name. 
  faName="${name%.bed*}.fa"    
  bedtools getfasta -s -fi $genome_path -bed $bedFile -name -fo $_pwd/fasta_files/$faName #Gets the sequence itself.
done

#Scans all the obtained fasta files.
for faFile in $_pwd/fasta_files/*.fa
do
  name=`basename $faFile`
  faOutput="${name}"
  bedOutput="${name%.fa*}.bed"
  #Filters the files for getting only those which contain dypirimidne in 2-3 columns. 
  cat $faFile  |\
  paste - -  |\
  awk 'toupper(substr($2,2,2)) ~ /^(TT|TC|CT|CC)$/' |\
  tr "\t" "\n" |\
  tee $_pwd/filtered_fasta/$faOutput |\ 
  awk -F '[>():-]' '/^>/ {printf("%s\t%s\t%s\t%s\t%s\t%s\n",$4,$5,$6,$2,$2,$7);}' > $_pwd/filtered_bed/$bedOutput 
done