Answer the question
In order to leave comments, you need to log in
How to wait for a for loop in a bash script?
Wrote a script for Nautilus that changes the encoding of selected files.
I want to display a notification after the end of the operation, but as far as I know, the loop is executed in a separate thread and the notification appears before it completes.
How to wait until the end of the loop?
#!/bin/bash
FROM=cp1251
TO=utf-8
ICONV="iconv -f $FROM -t $TO"
for file in [email protected]
do
if [ -f $file ]; then
tmpf="/tmp/${file}.bak"
cp ${file} ${tmpf}
$ICONV < ${tmpf} > ${file}
rm ${tmpf}
fi
done
# /usr/share/icons/hicolor/48x48/apps/
# Параметр -i - имя иконки без расширения
notify-send -i ktip "Операция завершена!" "Кодировка файлов изменена на UTF-8"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question