Reputation: 51
I have a file with this strings
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 ";
I want to delete the spaces in the name
field.
How can I obtain this:
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";
Please Help me
I tried: cut test.txt | cut -d ' ' -f1,2,3,4,5,6
but it doesn't work
Upvotes: 0
Views: 331
Reputation: 4969
This is more a job for sed
than for bash.
sed 's/ *";/";/' test.txt
or (as a demonstration with a here-document):
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";
Upvotes: 2