我在下面有这个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) 在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) 以下内容无效 -
public partial class form1 : Form : ICloneable
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法在表单类上使用ICloneable?
用目录结构说,例如:
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.