2017-05-14 8 views
-1

dirを別のディレクトリにハードリンクしたいが、このスクリプトは動作しない。それはいくつかの奇妙な理由のためにすべてのディレクトリにハードリンクします。 "tv show dir"は 'moviesdestpath'、 'tvdestdestpath'、 'miscdestpath'にハードリンクされますbashハードリンクが動作しない

アイデア?

#!/bin/bash 
tvdestpath="/rpn-san/downloads/complete/torrents/tvshows-ready/$2" 
moviedestpath="/rpn-san/downloads/complete/torrents/movies-ready/$2" 
miscdestpath="/rpn-san/downloads/complete/torrents/misc-ready/$2" 
torrentid="$1" 
torrentname="$2" 
torrentpath="$3" 
torrentdir="$torrentpath/$torrentname" 

#hardlink to "tvshows-ready" 
cp -al "$torrentdir" "$tvdestpath/" 
sleep 5 
cp -al "$torrentdir" "$moviesdestpath/" 
sleep 5 
cp -al "$torrentdir" "$miscdestpath/" 
+0

ご覧ください:http://www.shellcheck.net/ – Cyrus

+0

私は 'cp'の' -l'オプションに慣れていません。どのバージョンのLinuxを使用していますか? – Beta

+3

Linuxはディレクトリへのハードリンクを許可していません。 – Barmar

答えて

-1

すべてがわかりました。私はばかです。私は文字通りすべてのディレクトリにコピーしています。

#!/bin/bash 
tvdestpath="/rpn-san/downloads/complete/torrents/tvshows-ready/$2" 
moviedestpath="/rpn-san/downloads/complete/torrents/movies-ready/$2" 
miscdestpath="/rpn-san/downloads/complete/torrents/misc-ready/$2" 
torrentid="$1" 
torrentname="$2" 
torrentpath="$3" 
torrentdir="$torrentpath/$torrentname" 

#hardlink to "tvshows-ready" 
if [ "$torrentpath" == "/rpn-san/downloads/complete/torrents/tvshows" ]; then 
cp -al "$torrentdir" "$tvdestpath/" 
fi 

sleep 5 
#hardlink to "movies-ready" 
if [ "$torrentpath" == "/rpn-san/downloads/complete/torrents/movies" ]; then 
cp -al "$torrentdir" "$moviedestpath/" 
fi 

sleep 5 
#hardlink to "misc-ready" 
if [ "$torrentpath" == "/rpn-san/downloads/complete/torrents/misc" ]; then 
cp -al "$torrentdir" "$miscdestpath/" 
fi 
関連する問題