【发布时间】:2016-10-28 17:22:47
【问题描述】:
我正在尝试添加 ||将正则表达式转换为 perl 脚本中的 bash `ed one-liner,如果这有意义的话。
my $result = `df -H | grep -vE '^Filesystem|tmpfs|cdrom|none' | awk '{ print \$1 "\t" \$5 " used."}'`;
# .Private maybe the same as /dev/sdb1 so I'm trying to remove it too
# by trying to add || (m/\.Private/) to the above
print "$result";
因此,我目前正在从输出中删除以 Filesystem、tmpfs、cdrom 或无开头的行,但如果可能的话,我也希望将“或包含 .Private 的行”添加到单行中。 .
我也有下面的,但想用上面的代码重现它的结果......
my @result2 =Shell::df ("-H");
shift @result2; # get rid of "Filesystem..."
for( @result2 ){
next if ((/^tmpfs|tmpfs|cdrom|none/) || (m/\.Private/));
my @words2 = split('\s+', $_);
print $words2[0], "\t", $words2[4], " used\.\n";
}
【问题讨论】:
-
这家伙大概是在学习和练习吧,他的问题没有错。我知道这是 4 岁,但值得一说。