Tag: SED

Remove non-ASCII characters from file

There was a text file that contained non-ASCII characters that acted like spaces within the file, so I used the tried and true dos2unix command to attempt to clean the file; however, the characters remained.  With hundreds of lines to correct, manually deleting the offending areas of the file was not an option.  A real solution is needed. Once again,…

Read More »

Reduce the number of commands with sed

Suppose there is a situation that a server has multiple files that are nearly identical and you want to remove content from them.  In this example suppose that server has multiple NIC cards.  There is content that needs to be deleted. The situation, you have five NIC cards.  Each ifcfg-ethx config file contains the values for NM_CONTROLLED, HWADDR, GATEWAY, and…

Read More »

How to escape double quotes in sed

A recent attempt to replace a string within double quotes “string value” while using sed resulted in much trial and error. A quick Internet search revealed a working answer.  It is here for my reference. I wanted to replace “this value” with “that one” in a file, we’ll call testfile.  According to multiple sources, the sed command allows the use…

Read More »

How to search and replace text from a very large XML file

There are many ‘solutions’ that exist that will parse through a text file and other utilities that have specific functions designed to parse through an XML file. After trying several applications only one was capable of effeciently search and replace text within (in this case) an XML file that is over 300 MB in size. The whole process took less…

Read More »