문제

I'm struggling to only retrieve subfolders from a remote windows share with the following directory structure using smbclient. Is there a way of issuing a command to only get folders? The command I have so far is:

smbclient //$host/$share -U"$USER%$PASSWORD" -c 'cd RootFolder; prompt; recurse; mget Test*\'

RootFolder/
    Test001/
        Revisions.txt
    Test002/
        Revisions.txt
    Test003/
        Revisions.txt
    Test001=2012_12_05.log
    Test001=2012_12_06.log
    Test001=2012_12_07.log
    Test001=2012_12_08.log
    ... more log files here
도움이 되었습니까?

해결책

You could pipe the output of your command through grep, looking for lines that end with /.

smbclient ... | egrep '/$'

Instead, you could mount the remote windows file system and then use the find command to search for folders. The find command will search recursively for all directories only. This would be my recommended approach. Assuming you mount the windows filesystem as /mnt/win_host...

find /mnt/win_host -type d
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top