perl -pi -e 's/$string_to_be_removed//g' full_path/one.txt #### #!/usr/bin/perl BEGIN {(*STDERR = *STDOUT) || die;} use diagnostics; use warnings; use strict; $| = 1; my $file = full_path/one.txt; @ARGV = $file; $^I = '~'; while (<>) { binmode ARGVOUT if $. == 1; s/$string_to_be_removed//g; print; }