我想知道如何制作执行以下操作的函数/脚本:
#!/bin/bash
last="$(cd /Users/xxxx/Pictures/xxx && ls -tU | head -n1)"
read -p "Would you like to rename it? " REPLY
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Enter the name: "
read -a name
mv -i /Users/xxxx/Pictures/xxx/$last /Users/xxxx/Pictures/Saved\ backgrounds/$name.jpg
echo "Saved as $name"
else
mv -i /Users/xxxx/Pictures/xxx/$last /Users/xxxx/Pictures/Saved\ backgrounds/$last
echo "Saved as $last"
fi
编辑:找到了解决方法。