Date: Sat, 8 Feb 2025 12:08:10 -0500 From: Greg Wooledge <g...@wooledge.org> Message-ID: <20250208170810.gl29...@wooledge.org>
| OK, I think you have something like this: | | while read -r f; do | if [[ $f = *[[:space:]]* ]]; then | read -r -p "Fix <$f>? " yn | fi | ... | done < mylistfile [...] | But if you need to do something like this in the future, you can use | a different file descriptor for the redirection: | | while read -r -u3 f; do | ... | read -r -p "Do it? " yn | ... | done 3< somefile And another way, which doesn't need non-standard -u options to read, is: exec 3<&1 while read -r f do case "$f" in (*[[:space:]]*) if read -r -p "Fix <$f> ? " yn <&3 then case "${yn}" in ([Yy]*) Rename_File "$f";; esac else break fi ;; esac done < "${List_of_files}" exec 3<&- Or even forget the file list, and certainly don't use ls -l when just a plain ls will do (assuming you don't need the rest of the info to decide whether to rename the file or not) exec 3<&1 ls | while read -r f do # same loop internals as above done exec 3<&- In all of this, beware file names containing newline characters, to deal with those, you need instead: exec 3<&1 find . -print0 | while read -d '' -r f do # same loop, perhaps also looking for \n in $f done exec 3<&- kre ps: there is almost never a good excuse to use non-standard sh extensions (bash's, or any other shells), when writing a standard conforming script would allow any Bourne shell variant to work, and that's certainly the case here, and in most other cases.