运行Shell脚本时找不到Mac Terminal Foreach命令

rails_newbie

我正在尝试在终端中运行脚本,但是却收到错误消息,即未找到foreach命令。在过去的6个小时里,我一直在尝试在线查找答案,但似乎什么也找不到。您能否让我知道为什么这超出了“ 20行:foreach:找不到命令”?

脚本在这里:

#!/bin/csh
# Source name: fa_extract
# Author name: ----
# Last modified by: Apr 29, 2013
# Date modified: Apr 29, 2013
# Program description: extract FA, AD, RA values
# Main function: extract FA, AD, RD, MD, into txt files
# Variable description: age; wt, waytotal


echo "# Source name: fa_extract"
echo "# Author name: ----"
echo "# Last modified by: Apr 29, 2013"
echo "# Date modified: Apr 29, 2013"
echo "# Program description: extract FA, AD, RA values"
echo "# Main function: extract FA, AD, RD, MD, into txt files"
echo "# Variable description: age; wt, waytotal"

#1st level
foreach sub$(01_007_c/01_007_c_L 01_007_c/01_007_c_R 01_012_c/01_012_c_L 01_012_c/01_012_c_R 01_013_c/01_013_c_L 01_013_c/01_013_c_R 01_014_c/01_014_c_L 01_014_c/01_014_c_R 01_015_c/01_015_c_L 01_015_c/01_015_c_R 01_029_p/01_029_p_L 01_029_p/01_029_p_R 01_035_p/01_035_p_L 01_035_p/01_035_p_R 01_036_p/01_036_p_L 01_036_p/01_036_p_R 01_037_p/01_037_p_L 01_037_p/01_037_p_R 01_038_p/01_038_p_L 01_038_p/01_038_p_R 01_040_p/01_040_p_L 01_040_p/01_040_p_R 01_041_p/01_041_p_L 01_041_p/01_041_p_R 01_042_p/01_042_p_L 01_042_p/01_042_p_R 01_043_p/01_034_p_L 01_043_p/01_043_p_R 01_044_p/01_044_p_L 01_044_p/01_044_p_R 01_045_p/01_045_p_L 01_045_p/01_045_p_R 01_046_p/01_046_p_L 01_046_p/01_046_p_R)

cd ~/Desktop/OBI_pre_process/DTI/Tractography/SLF/${sub}/

echo "----------------------------------------------------------------------------------------------------------"
pwd


set wt=`cut -f2 -d '' waytotal`#normalization by waytotal
echo "waytotal = $wt"
fslmaths fdt_paths.nii.gz -div $wt fdt_paths_fa_norm.nii.gz 
fslmaths fdt_paths_fa_norm.nii.gz -thrP 40 -bin fdt_paths_fa_bin.nii.gz # threshold by thrP40 & binarize

fslmaths *_DTI_FA.nii.gz -mas fdt_paths_fa_bin.nii.gz fa_masked.nii.gz # masking FA maps...................FA
fslstats fa_masked.nii.gz -M > fa.txt

fslmaths *_DTI_L2.nii.gz -mas fdt_paths_fa_bin.nii.gz L2_masked.nii.gz # masking L maps..................RD
fslmaths *_DTI_L3.nii.gz -mas fdt_paths_fa_bin.nii.gz L3_masked.nii.gz
fslmaths L2_masked.nii.gz -add L3_masked.nii.gz L2_L3_masked.nii.gz
fslmaths L2_L3_masked.nii.gz -div 2 rd.nii.gz
fslstats rd.nii.gz -M > rd.txt

fslmaths *_DTI_L1.nii.gz -mas fdt_paths_fa_bin.nii.gz ad.nii.gz # masking L maps..................AD
fslstats ad.nii.gz -M > ad.txt

fslmaths *_DTI_MD.nii.gz -mas fdt_paths_fa_bin.nii.gz md.nii.gz # masking L maps..................MD
fslstats md.nii.gz -M > md.txt

end # <<<<<<<<<subject loop ends
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>1st level done" 

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2nd level

rm -rf /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/fa/athletes*.txt
rm -rf /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/fa/controls*.txt


# athletes
foreach sub$(01_007_c/01_007_c_L 01_007_c/01_007_c_R 01_012_c/01_012_c_L 01_012_c/01_012_c_R 01_013_c/01_013_c_L 01_013_c/01_013_c_R 01_014_c/01_014_c_L 01_014_c/01_014_c_R 01_015_c/01_015_c_L 01_015_c/01_015_c_R 01_029_p/01_029_p_L 01_029_p/01_029_p_R 01_035_p/01_035_p_L 01_035_p/01_035_p_R 01_036_p/01_036_p_L 01_036_p/01_036_p_R 01_037_p/01_037_p_L 01_037_p/01_037_p_R 01_038_p/01_038_p_L 01_038_p/01_038_p_R 01_040_p/01_040_p_L 01_040_p/01_040_p_R 01_041_p/01_041_p_L 01_041_p/01_041_p_R 01_042_p/01_042_p_L 01_042_p/01_042_p_R 01_043_p/01_034_p_L 01_043_p/01_043_p_R 01_044_p/01_044_p_L 01_044_p/01_044_p_R 01_045_p/01_045_p_L 01_045_p/01_045_p_R 01_046_p/01_046_p_L 01_046_p/01_046_p_R)

cd /Desktop/OBI_pre_process/DTI/Tractography/SLF/${sub}/
cat             fa.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athletes_fa.txt
cat             rd.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athletes_rd.txt
cat             ad.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athletes_ad.txt
cat             md.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athletes_md.txt
#cat            ../age.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athltes_age.txt
cat           ../seg_0.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athletes_seg_0.txt
cat               ../seg_1.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athletes_seg_1.txt
cat               ../seg_2.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/athletes_seg_2.txt

end
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>2nd level athletes done" 

# controls
foreach sub$(01_007_c/01_007_c_L 01_007_c/01_007_c_R 01_012_c/01_012_c_L 01_012_c/01_012_c_R 01_013_c/01_013_c_L 01_013_c/01_013_c_R 01_014_c/01_014_c_L 01_014_c/01_014_c_R 01_015_c/01_015_c_L 01_015_c/01_015_c_R 01_029_p/01_029_p_L 01_029_p/01_029_p_R 01_035_p/01_035_p_L 01_035_p/01_035_p_R 01_036_p/01_036_p_L 01_036_p/01_036_p_R 01_037_p/01_037_p_L 01_037_p/01_037_p_R 01_038_p/01_038_p_L 01_038_p/01_038_p_R 01_040_p/01_040_p_L 01_040_p/01_040_p_R 01_041_p/01_041_p_L 01_041_p/01_041_p_R 01_042_p/01_042_p_L 01_042_p/01_042_p_R 01_043_p/01_034_p_L 01_043_p/01_043_p_R 01_044_p/01_044_p_L 01_044_p/01_044_p_R 01_045_p/01_045_p_L 01_045_p/01_045_p_R 01_046_p/01_046_p_L 01_046_p/01_046_p_R)# >>>>>>>>>subject loop

cd /Desktop/OBI_pre_process/DTI/Tractography/SLF/${sub}/
cat             fa.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_fa.txt
cat             rd.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_rd.txt
cat             ad.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_ad.txt
cat             md.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_md.txt
#cat            ../age.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_age.txt
cat           ../seg_0.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_seg_0.txt
cat           ../seg_1.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_seg_1.txt
cat           ../seg_2.txt >> /Desktop/OBI_pre_process/DTI/Tractography/SLF/2nd_level/thrP40/N21_17/controls_seg_2.txt

end
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>2nd level controls done" 
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>ALL DONE !" 
普拉迪·乔德

之所以失败,是因为csh没有其他Shell可以执行foreach循环。因此,如果您尝试通过任何其他外壳执行脚本,它将失败。

因为已经有了,#!/bin/csh您可以使用执行脚本,./scriptname但是如果要在其他shell中执行脚本,则可以使用------

用以下内容替换每一行

for sub in $(echo "all the strings seperated by a space")
 do 

 \# rest of your script inside for should come here

done         #done is replacing end in your case

如果您不能使用,echo "string SEPERATED by spaces"则可以使用cut现有的分度计。

我无法在foreach语句中计算出您正在使用的度量值。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

找不到Mac terminal -bash命令?

来自分类Dev

运行Shell脚本时出现“找不到命令”错误

来自分类Dev

找不到在Shell脚本中运行的命令

来自分类Dev

运行shell脚本时出现“找不到命令”。我弄坏了什么?

来自分类Dev

在Shell脚本中调用函数时找不到命令

来自分类Dev

-bash::在Mac OSX中启动Shell时找不到命令

来自分类Dev

通过cron运行脚本时出现“找不到命令”

来自分类Dev

运行脚本时找不到重命名命令

来自分类Dev

通过 cron 运行脚本时“找不到命令”

来自分类Dev

在Shell脚本中找不到命令

来自分类Dev

Shell脚本:找不到命令错误

来自分类Dev

在shell脚本中找不到date命令

来自分类Dev

在Shell脚本中找不到命令

来自分类Dev

在Shell脚本中找不到命令

来自分类Dev

找不到Shell脚本Ruby命令

来自分类Dev

Shell脚本:pacmd:找不到命令

来自分类Dev

在shell / bash脚本中找不到命令

来自分类Dev

从shell脚本中捕获“找不到命令”

来自分类Dev

Shell脚本错误:找不到命令

来自分类Dev

运行 Bash 脚本时找不到命令,但直接运行命令时有效

来自分类Dev

为什么我的Mac Terminal命令在Shell脚本中不起作用?

来自分类Dev

Shell脚本返回“正在运行:找不到命令”。不知道为什么

来自分类Dev

从命令行运行mfp时在Mac上找不到命令错误

来自分类Dev

Mac Terminal查找和打开命令

来自分类Dev

Mac Terminal查找和打开命令

来自分类Dev

Mac Terminal查找命令无法查看目录

来自分类Dev

运行.bashrc时找不到别名命令

来自分类Dev

从命令行运行R脚本时找不到setClass

来自分类Dev

在脚本文件中运行定义的函数时找不到命令

Related 相关文章

热门标签

归档