Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如果生成了一个新文件,则为Cat_Linux_Scripting_Monitor - Fatal编程技术网

Linux 如果生成了一个新文件,则为Cat

Linux 如果生成了一个新文件,则为Cat,linux,scripting,monitor,Linux,Scripting,Monitor,我有一个脚本谁生成一个新的文件,如果一个新的电子邮件已到达与fetchmail procmail新的电子邮件出现在一个普通的文件,我需要处理电子邮件的内容,如果有一个新的。 fetchmail的日志示例: procmail: [7709] Fri Jul 12 09:10:19 2019 procmail: Assigning "LASTFOLDER=Mail/new/1562933419.7709_0.localhost.localdomain" Folder: Mail/new/15629

我有一个脚本谁生成一个新的文件,如果一个新的电子邮件已到达与fetchmail procmail新的电子邮件出现在一个普通的文件,我需要处理电子邮件的内容,如果有一个新的。 fetchmail的日志示例:

procmail: [7709] Fri Jul 12 09:10:19 2019
procmail: Assigning 
"LASTFOLDER=Mail/new/1562933419.7709_0.localhost.localdomain"
Folder: Mail/new/1562933419.7709_0.localhost.localdomain 38398
只有当有一封新邮件并对其进行处理时,我才需要检索此信息—更改原始接收文件的格式,然后将其复制到其他目录,然后清理此原始文件

一些简单的实现方法?

inotifywait inotify tools的一部分是实现目标的工具:

下面是一个示例脚本:

#!/bin/sh
MONITORDIR="/path/to/the/dir/to/monitor/"
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE
do
    mv NEWFILE /path/to/newdir
更多示例如下:


我已经测试了目录脚本的监视器,也许更改部分可以对新文件进行cat以应用格式更改。filesindir=ls-t/Mail/new for i in$filesindir do echo$listOF | grep$i if[[$?-eq 0]]那么listOF=$listOF$i fi doneJww im new in stackoverflow,如果预期或如果im脱离主题,则表示抱歉。。我不理解这里的一切,别担心。当开始堆栈溢出时,每个人都会有点生气。这些都非常重要。