Bash 3.2.52(2)がインストールされているCentOSでは、あるディレクトリから別のディレクトリに多くのファイル(すべてではない)をコピーする必要があります。
たとえば、非常に長い行を作成することもできますが、cp /"$HOME"/dir1/{file1,fil2} ... /"$HOME"/dir2
dir1には多くのファイルがあるため、ファイルを複数行にコピーすることをお勧めします。
編集:リストを手動で作成します。
これはどのように達成できますか?
バックスラッシュのないソリューションを好む手がかりが見つかりませんでしたman cp
。ここには文書だけがあるようです。
ベストアンサー1
files=(
file1 file2 "the goose incident.png"
"another file"
file3 file-4 "fifth file" file6
"this is file7 with a
newline in the middle of the name" )
cd ~/dir1 &&
cp "${files[@]}" ~/dir2
files
これにより、リストに記載されている名前が~/dir1
にコピーされます~/dir2
。
リストの要素間の改行はfiles
重要ではありません。ただし、最後の要素の改行はファイル名に改行が含まれています(単に問題なくこれらの行も使用できることを示すためのものです)。
リストは次のように書くこともできます。
files=(
file1
file2
"the goose incident.png"
"another file"
file3
file-4
"fifth file"
file6
"this is file7 with a
newline in the middle of the name"
)
または
files=( file1 file2 "the goose incident.png" "another file" file3 file-4
"fifth file" file6 "this is file7 with a
newline in the middle of the name" )