一种解决方案是完全删除该行,并依靠文件系统来跟踪创建/修改日期。这可以使用常见的 shell 工具以多种方式完成:
# sed
sed -i file.eps '/^%%CreationDate: /d'
或者
# grep
grep -v '^%%CreationDate: ' file.eps > tmp && mv tmp file.eps
如果您在 Windows 机器上,MATLAB 应该包含一个 Perl 解释器:
# perl
perl -i -ne 'print if not /^%%CreationDate: /' file.eps
在 MATLAB 中,您可以执行以下操作来调用单行 Perl 程序:
%# construct command, arguments and input filename (with quotes to escape spaces)
cmd = ['"' fullfile(matlabroot, 'sys\perl\win32\bin\perl.exe') '"'];
args = ' -i.bak -ne "print if not /^%%CreationDate: /" ';
fname = ['"' fullfile(pwd,'file.eps') '"'];
%# execute command
system([cmd args fname])