2014-02-28 77 views
0

我正在嘗試編寫一個簡短的函數,它將從主目錄轉到特定的文件夾,然後查找過去幾天內訪問過的任何文件。-f未知的選項bash

function restore5 { 
    cd /Volumes/FTP/RESTORES 
    find . type -f -atime +5 | less 
} 

當我運行這個函數時,我收到一個錯誤:find:-f:unknown option。 當我手動鍵入命令時,我沒有得到這個錯誤代碼,所以我很想知道我錯過了什麼?

此外,如果我想擴大這一點,並添加到函數的結尾如果不成功的類型命令,將「| |」是更合適的命令來使用?我的思緒沿着線分別爲:

| | echo "No files found" 
+0

我會傾向於pipe找到wc -l並對結果進行數字測試以顯示消息 – scoota269

回答

2

應該find . -type f -atime +5 | less

0

,你應該不使用

find . - type f -atime +5 | less 

摘自發現的手冊頁:

-type c 
      File is of type c: 

      b  block (buffered) special 

      c  character (unbuffered) special 

      d  directory 

      p  named pipe (FIFO) 

      f  regular file 

      l  symbolic link; this is never true if the -L option or the -follow option is in effect, unless the symbolic link is broken. If you 
       want to search for symbolic links when -L is in effect, use -xtype. 

      s  socket 

      D  door (Solaris) 
0

展望通過手冊查找類型命令的語法是- 鍵入f嘗試使用該名稱而不是您的。鍵入-f

不知道你是否正在用做點什麼。鍵入,我不明白,但希望它有幫助。