Macos 管道传输特定的find命令并从其输出创建zipfile时出错?
我希望创建一个程序,该程序可以压缩在find参数指定的目录中创建的任何文件,并将其作为后台进程运行。我对它进行了大量的评论,以便更好地了解我正在努力实现的目标。我在MacBookPro终端上运行这个,OSX版本10.9Macos 管道传输特定的find命令并从其输出创建zipfile时出错?,macos,shell,unix,zip,pipe,Macos,Shell,Unix,Zip,Pipe,我希望创建一个程序,该程序可以压缩在find参数指定的目录中创建的任何文件,并将其作为后台进程运行。我对它进行了大量的评论,以便更好地了解我正在努力实现的目标。我在MacBookPro终端上运行这个,OSX版本10.9 #!/bin/sh #find file in directory listed below #type f to omit directories or special files #mtime/ctime is modified/created -0 day
#!/bin/sh
#find file in directory listed below
#type f to omit directories or special files
#mtime/ctime is modified/created -0 days or less
#name is with the name given in double quotes
#asterik meaning any file name with any file extension
#use xargs to convert find sequence to a command for the line after pipe
find /Users/name/thisdirectory type f -ctime -0 -name "'*'.'*'" | xargs zip -
也许你在找这个:
find /path/to/dir -type f -ctime -0 -name "*.*" | zip -@ file.zip
如果您阅读zip-h
,它说明-@
是从标准输入读取文件名
这里不需要xargs
,处理从标准输入接收的文件列表的功能内置于zip
本身,类似于大多数压缩工具,如tar
顺便说一句,我想你想更改-ctime-0
,因为我认为它不能以这种方式匹配任何东西