#!/bin/bash
IFS='\n'
declare -i count=0
AX=$(find *.iso -maxdepth 1 -type f) # Rather use AX="$(find *.iso -maxdepth 1 -type f"?
# A="${AX%x}" < Could I use this when applying "" to $() in AX? But it should already include newlines like this way. edit: I don't need the trailing newlines fix.
for iso in "$AX"
do
echo "Use "$iso"? [Y/N]?" # Outputs ALL files, IFS has no force somehow
read choiceoffile
shopt -s nocasematch
case $choiceoffile in
y ) echo "Using selected file.";;
* ) continue;;
esac
# some sort of processing
done
命令替换是否正确?该变量不适用于 for 循环中的 IFS \n,我不明白为什么会发生这种情况。
for 循环应该通过逐行处理 find 的输出来处理带有空格的文件名(这就是我使用 IFS \n 的原因)。