Answers:
libc realpath()
函数可以通过解析所有符号链接完成大部分工作; 编写与此类似的脚本来过滤唯一结果:
#!/usr/bin/env perl
use Cwd;
my %files = map {Cwd::realpath($_) => 1} @ARGV;
my @files = sort keys %files;
# This example will run: mycommand arg1 arg2 file1 file2 file3 arg3
system {"mycommand"} "mycommand", "arg1", "arg2", @files, "arg3";
文件列表取自命令行参数。
uniquefiles.pl mydirectory/*
Type of arg 1 to keys must be hash (not anonymous hash ({})) at /home/alex/bin/uniquefiles.pl line 3, near "};"