Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
イメージ ファイルをディレクトリに配置しています。
"/root/Desktop/my test dir/image.jpg"
イメージ ファイルの名前を次のように変更する必要があります (シェル スクリプトを使用)。
image.jpg => "my test dir.jpg"
注: このディレクトリには 1 つのイメージ ファイルしかありません
誰かヒントを教えてください。
ありがとう。
パラメータ置換。
echo "${pathname##*/}" echo "${pathname%.*}"
できるよ:
x="/root/Desktop/my test dir/image.jpg" IFS="/" arr=( "$x" ) mv "$x" "${arr[1]}/${arr[2]}/${arr[3]}/${arr[3]}.${arr[4]##*.}"