我知道这通常与递归有关,但我很确定我没有这样做。在每次循环中,它都会给出一个指向 for 循环行的分段错误。
for file in $DATAFOLDER*; do
echo $file;
filename=$(basename $file);
echo $filename;
echo "$DESTFOLDER$SUBFOLDER${filename%%.*}"
pwd
# move data to cppapplication folder
cp -R "$file" "$DESTFOLDER";
sleep 1
# create subdirectory
mkdir "$SUBFOLDER";
# create new folder for extracted data
mkdir "$DESTFOLDER$SUBFOLDER${filename%%.*}";
# copy MassLynx header file into new folder (get the description info)
cp "$file/_HEADER.TXT" "$DESTFOLDER$SUBFOLDER${filename%%.*}";
# run the cppapplication
# <program> <project file> <MassSpectrum> <Mobilogram> <bins in Da> <extract m/z ranges>
./cppapplication.exe "$filename" 0 1 1 0 ;
# fix last character comma bug
sed -i '$ s/,$//g' MassMobility.txt
# move the created files into the new folder
mv Mobilogram.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}";
mv MassMobility.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}";
mv MassMobilityXaxis.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}";
mv MassMobilityYaxis.txt "$DESTFOLDER$SUBFOLDER${filename%%.*}";
# get driftscope quicklook image
sleep 3
python "C:\Users\ganesh\Dropbox\PhD\03_Amphitrite\CppApplication\quicklook_driftscope.py" "$DESTFOLDERWINDOWS$SUBFOLDERWINDOWS" "${filename%%.*}" "$DESTFOLDERWINDOWS$SUBFOLDERWINDOWS${filename%%.*}";
# remove MassLynx Project
rm -r "$filename";
done
除了文件的复制之外,我认为循环与循环通过的原始文件夹没有任何联系。
这是错误:
./extract_all_projects.sh: line 26: 7500 Segmentation fault (core dumped)
我不知道问题是什么,因为如果在 bash 脚本之外运行,“cppapplication.exe”在这些文件上运行良好。