我試圖使用perl
從目錄輸出中的所有文本文件中提取特定字段到一個新文件,每個文本文件放在一個新行中。提取特定字段並與perl合併爲1個文本文件
輸入
#Sample = xxxxx
#Sample Type = xxxxxx
#Build = xxxxxxx
#Platform = xxxxxxx
#Display Name= XXXXX (keep this field without the #)
#identifier = xxxxxx (keep this field without the #)
#Gender = xxxxx (keep this field without the #)
#Control Gender = xxxxx
#Control Sample = xxxxx
#Quality = X.XXXXXX (keep this field without the # and X.XXX)
所需的輸出(字段,每個文本文件保存)
Display Name= XXXXX (keep this field without the #)
identifier = xxxxxx (keep this field without the #)
Gender = xxxxx (keep this field without the #)
我把@Borodin建議在以前的帖子,並試圖腳本來實現這一點我認爲是接近的:
perl
#!/bin/perl
use strict; use warnings;
perl -ne '(s/^#(Display Name|identifier|Gender)/$1/ or s/^#(Quality = \d\.\d{3})\d+/$1/) and print' *.txt > all.txt
perl "C:\cygwin\home\get_all_qc2.pl"
syntax error at C:\cygwin\home\get_all_qc2.pl line 3, near "-ne"
Execution of C:\cygwin\home\get_all_qc2.pl aborted due to compilation errors.
謝謝:)。
你在你的Perl腳本中編寫了命令行perl調用? – Ven
你知道任何Perl嗎? – melpomene
是的,我用'perl「C:\ cygwin \ home \ get_all.pl」'謝謝你:)來調用它。 – Chris