我有一个包含此字符串的文件
select chrom,chromStart,chromEnd,name from snp147 where name="rs12414460 ";
select chrom,chromStart,chromEnd,name from snp147 where name="rs12456 ";
select chrom,chromStart,chromEnd,name from snp147 where name="rs12434212334 ";
我想删除name
字段中的空格。
我怎样才能获得这个:
select chrom,chromStart,chromEnd,name from snp147 where name="rs12414460";
select chrom,chromStart,chromEnd,name from snp147 where name="rs12456";
select chrom,chromStart,chromEnd,name from snp147 where name="rs1243421111111";
请帮帮我
我尝试过:cut test.txt | cut -d ' ' -f1,2,3,4,5,6
但它不起作用
答案 0 :(得分:2)
sed
这比bash更多。
sed 's/ *";/";/' test.txt
或(作为本文档的演示):
sed 's/ *";/";/' <<EOF
> select chrom,chromStart,chromEnd,name from snp147 where name="rs12414460 ";
> select chrom,chromStart,chromEnd,name from snp147 where name="rs12456 ";
> select chrom,chromStart,chromEnd,name from snp147 where name="rs12434212334 ";
> EOF
select chrom,chromStart,chromEnd,name from snp147 where name="rs12414460";
select chrom,chromStart,chromEnd,name from snp147 where name="rs12456";
select chrom,chromStart,chromEnd,name from snp147 where name="rs12434212334";