What is the proper way to remove all hidden and non-hidden files and folders recursively in a target directory without receiving the warning/error about. and..?
Предположим, что речь идет о каталоге ./dir
, тогда
rm -rf./dir
удалит все файлы в ./dir
, включая скрытые файлы и каталоги, рекурсивно, включая сам каталог ./dir
.
Если вы не хотите удалять сам каталог, вы можете просто создать его заново или использовать
find./dir -mindepth 1 -delete
или если вы find
не поддерживаете -delete
,
find./dir -mindepth 1 -depth -exec rm -rf {} ';'
Использование -mindepth 1
позволяет сохранить каталог верхнего -уровня ./dir
.
echo -n "1" >&5
помог мне. Похоже, uboot не хочет получать новую строку, иначе он ведет себя странно.
Большое спасибо за помощь!
Вот "полный" скрипт, может кому пригодится.
#!/bin/bash
tty=/dev/ttyUSB0
exec 4<$tty 5>$tty
stty -F $tty 115200 -brkint -icrnl -imaxbel iutf8 -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
tftp_client_ip="10.10.30.111"
tftp_server_ip="10.10.30.1"
tftp_file="test.file"
while [ "$firstword" != "Please" ]; do # wait for bootmenu to apear
read -e output <&4
firstword=$(echo "$output" | cut -f1 -d" ")
echo "$output"
done
#printf "\t\n ***** ***** gotcha! ***** ***** \n\n"
sleep 0.5
# DONT SEND NEWLINEs - otherwise uboot doesn´t recognize commands !!!!!
echo -n "1" >&5 # echo '1' for taking boot option 1
printf "\t\n ***** ***** echo '1' ***** ***** \n\n"
# MUST TO WAIT FOR DELAY - try to fix that by "emulate" RETURN button?
sleep 5
#input TFTP-client IP
for((i=0;i<20;i++)); do
echo -ne "\b \b" >&5 #erase characters
sleep 0.05
done
printf "%s\r" "$tftp_client_ip" >&5
#input TFTP-server IP
for((i=0;i<20;i++)); do
echo -ne "\b \b" >&5 #erase characters
sleep 0.05
done
printf "%s\r" "$tftp_server_ip" >&5
#input TFTP-file
printf "%s\r" "$tftp_file" >&5
while true; do #just for debugging...
read -e output <&4
echo "$output"
done
# router should boot to RAM with "$tftp_file"