小编too*_*oop的帖子

perl - 将系统命令重定向到文件

我在下面有这个perl代码,基本上想循环这两个文件.然后调用一个bash脚本(它将文件和分隔符作为参数并打印出多行),然后将该命令的所有输出保存到一个新文件中(文件名末尾加上'_processed').以下语法有什么问题(目前它只创建一个空白文件)?

#!/usr/bin/env perl
use strict;
use warnings;

my(@files) = (
"fixedtt.txt '|'",
"delimd2iffpipe.dat '|'"
);
for my $i (0 .. $#files) {
    my($filename) = split /[\s]+/, "$files[$i]", 2;
    my($name, $type) = split /[\.]+/, "$filename", 2;
    open (MYFILE, '>'."$name".'_processed.'."$type");
    system("sh myBashScript.sh $files[$i]");   #I want to write the entire output of this command to a file
    close (MYFILE); 
}
Run Code Online (Sandbox Code Playgroud)

unix linux bash shell perl

0
推荐指数
1
解决办法
4483
查看次数

unix - awk - 在用户定义的函数中打印参数名称

在bash脚本中使用下面的awk说:

如何让print_line函数打印传入的参数的名称?即这个输出

array passed in was:
arrayprime
array passed in was:
arraymagic
Run Code Online (Sandbox Code Playgroud)

只是代码要点的片段(不是整件事):

awk -F"$delim" '
NR>1 { 

        print_line(arrayprime)
        print_line(arraymagic)
}
    func print_line(arr)
    {
        print "array passed in was:"
            print arr
    }

} ' "$filename"
Run Code Online (Sandbox Code Playgroud)

unix linux bash shell awk

0
推荐指数
1
解决办法
370
查看次数

如何实现接口并从基类继承?

以下内容无效 -

public partial class form1 : Form : ICloneable 
Run Code Online (Sandbox Code Playgroud)

有没有一种简单的方法在表单类上使用ICloneable?

.net c#

-1
推荐指数
1
解决办法
87
查看次数

unix - 仅从目录中删除文件

用目录结构说,例如:

toplev/
      file2.txt
      file5.txt
      midlev/
            test.txt
            anotherdirec/
                         other.dat
                         myfile.txt
                         furtherdown/
                                    morefiles.txt
                         otherdirec/
                                    myfile4.txt
                                    file7.txt
Run Code Online (Sandbox Code Playgroud)

你会如何从'anotherdirec'中删除所有文件(不是目录而不是递归)?在这个例子中,它将删除2个文件(other.dat,myfile.txt)

我在'midlev'目录中尝试了下面的命令,但是它给出了这个错误(find: bad option -maxdepth find: [-H | -L] path-list predicate-list):

find anotherdirec/ -type f -maxdepth 1
Run Code Online (Sandbox Code Playgroud)

我正在运行SunOS 5.10.

unix bash shell perl solaris

-1
推荐指数
1
解决办法
1006
查看次数

标签 统计

bash ×3

shell ×3

unix ×3

linux ×2

perl ×2

.net ×1

awk ×1

c# ×1

solaris ×1