~/desktopにsampleディレクトリがあり、このディレクトリの中に複数のファイルが入っています。
このファイルから特定の文字列を含むファイルをxargsに渡して、ファイル名の頭に"1.1_"を追加するコマンドを知りたいです。
たとえば、
2018_abc_1221.jpg → 1.1_2018_abc_1221.jpg
といったようにファイル名を変換したいです。
##環境
・macOS High Sierra
・バージョン 10.13.6
##試したこと
以下の2つのコマンドを実行しましたが、うまくいきませんでした。
① find ~/desktop/sample -name "*abc*" -maxdepth 1 | xargs -J % mv % 1.1-% ② find ~/desktop/sample -name "*abc*" -maxdepth 1 | xargs -i mv {} 1.1-{}
①のコマンドを実行すると、
usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory
②のコマンドを実行すると、
xargs: illegal option -- i
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
と返ってきます。
正しいコマンドを知りたいです。
何かご教示いただけることがあれば、何卒よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/21 02:42
2018/12/21 02:45
2018/12/21 02:50 編集
2018/12/21 03:19
2018/12/21 03:39
2018/12/21 03:54