2017-05-14 2 views
-1

Ich möchte ein Verzeichnis an ein anderes Verzeichnis Hardlink, aber dieses Skript funktioniert nicht. Es enthält aus irgendeinem seltsamen Grund Hardlinks zu allen Verzeichnissen. so wird "tv show dir" in "moviesdestpath", "tvdestdestpath" und "miscdestpath" verlinktBash Hardlinking funktioniert nicht

irgendwelche ideen?

#!/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

Bitte nehmen Sie sich einen Blick: http://www.shellcheck.net/ – Cyrus

+0

Ich bin nicht vertraut mit der '-l' Option' cp'. Welche Version von Linux verwendest du? – Beta

+3

Linux erlaubt keine festen Links zu Verzeichnissen. – Barmar

Antwort

-1

Alles gut herausgefunden, ich bin ein Idiot. Ich kopiere buchstäblich in alle Verzeichnisse, wenn ich nicht sein sollte.

#!/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