我有一个名为test.txt的文件名,内容如下。awk gsub in perl
cat test.txt
MOD_12345_67890
我需要的文件
在摆脱 “mod_个” 我Perl中
my $file = `awk '{gsub("MOD_", "");print}' test.txt`;
。它删除MOD_并按预期打印12345_67890,但输出后有更多空格。
我的输出语句是
my $new_file = $file . ".dat";
print "$new_file";
我的输出应该如下。
12345_67890.dat
,但我得到的输出作为
12345_67890
.dat
.DAT在下一行即将
谁能帮我去掉空格或垃圾值后的数字输出应该是12345_67890.dat
.dat是一个打印语句。 不应该将.dat添加到perl或awk语句。 只是想摆脱test.txt中的空格 – user1603530
如果行是换行符,而不是空格,您会在末尾看到什么。 – tripleee