2
votes
1answer
374 views

Replace spaces and tabs at the end of the line in all files

I need to replace all unwanted spaces in all files from the current directory and from directories from the current directory (recursive search). I define the unwanted spaces the spaces and tabs that ...
5
votes
3answers
5k views

Use sed to find whole word and replace

I have the following block of text in a file: test3.legacy test4.legacy test3 test3.kami I only want to search for test3 as a whole and replace it with nothing. Unfortunately, all my attempts have ...
1
vote
2answers
469 views

How to find and replace files contents that match a pattern?

Suppose we have a folder named Project. I would like find each file in the folder that contains the pattern &$ at the function call. For example should replace: AnyFunction(&$arg); with ...
2
votes
1answer
261 views

Replace “<?php print t('Blabla'); ?>” to be “Blabla”

Lets say in file.php, there is lots of php print text: <?php print t('Blabla'); ?>, <?php print t('Text Here'); ?>, etc. What I need is to remove <?php print t(' and '); ?> of the ...
2
votes
2answers
2k views

regex replace text in xml file within node from the command line

I have an XML file and I would like to replace everything that is between the open and closing tag within multiple instances of the g:gtin node with nothing. Is this possible from the command line, ...
4
votes
4answers
933 views

Replace whole line in a file from command-line

I have a text file which has some contents similar to this: # General information about the project. project = u'Py6S' copyright = u'2012, Robin Wilson' # The version info for the project you're ...
9
votes
11answers
8k views

How can I “cat” a file and remove commented lines?

I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ; For example, if the file contained this: ; - Show all errors, except for notices ; ...