Skip to content

cybercomsweden/batch-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Batch replace

Build Status

Batch replace allows non-trivial refactoring where a simple awk or find replace command doesn't work. A typical scenario is to replace foo with bar and bar with foo. The replacements need to be performed simultaneously or one will totally replace the other. Batch replace scans the original file line by line and performs replacements on the fly.

Usage example

Imagine we want to replace foo with bar and bar with foo in the following text file (example.txt):

foo is sillier than bar

We then need to create another text file (replacements.txt) with replacements. The replacements are grouped pair-wise by line:

foo
bar

bar
foo

Pairs do not need to have a blank line between them, but can have for additional clarity. To run the program, simply call it with this command:

batchr replacements.txt example.txt

example.txt now looks like this:

bar is sillier than foo

Technical notes

The program is written in C++11 and requires headers for the experimental filesystem API (<experimental/filesystem>). Compilation requires at least GCC 5.3 or Clang 3.9.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •