Results 1 to 3 of 3
Hi, I feel silly for asking this, but how do you delete a pattern using tr?
I did this in a perl script:
Code:
system("cat $scrapedFile | tr --delete /M ...
- 01-05-2010 #1Just Joined!
- Join Date
- Sep 2008
- Posts
- 18
How to delete a pattern with tr
Hi, I feel silly for asking this, but how do you delete a pattern using tr?
I did this in a perl script:
Which seems okay, until I just realized it deletes all capital M's, too. I only want it to delete when the specific pattern /M is found. I've tried different ways, but keep failing.Code:system("cat $scrapedFile | tr --delete /M >$charsRemovedFile");
Thanks,
James
- 01-06-2010 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
do everything in Perl if you are using Perl.
Code:open( F,"<" ,"file") or die "Cannot read file:$!\n"; while(my $line = <F>){ # see perldoc -f tr }
- 01-06-2010 #3Just Joined!
- Join Date
- Sep 2008
- Posts
- 18
Thanks, that got me on my way. You've helped my meager perl knowledge go up a step


Reply With Quote