2

ある種のごみ箱を作ろうとしています。選択したファイルをごみ箱に送り、保存されていたディレクトリの場所をファイルに追加する削除機能があります。問題は、tailを使用してスクリプトから場所を取得するときです。スクリプトは機能しますが、ファイルの名前をtailに変更します。cpがファイルの名前を変更している理由を誰かが説明できますか?これが問題だと私が信じているところからの抜粋です:

destination=(tail $1 -n 1)
cp ~/Recycling/$1 $destination 
rm ~/Recycling/$1

ありがとう

4

3 に答える 3

2

$括弧の前にa が必要です。

destination=$(tail $1 -n 1)
cp ~/Recycling/$1 $destination 
rm ~/Recycling/$1
sed -i '$d' $destination # this removes the last line from the file
于 2012-11-27T01:20:59.127 に答える
1

$括弧の前にa がありません:

destination=$(tail $1 -n 1)
于 2012-11-27T01:21:03.537 に答える
0

あなたはしたいでしょう

$(tail $1 -n 1)

また

`tail $1 -n 1`
于 2012-11-27T01:21:18.477 に答える