SSR: Simple Search & Replace
HOWTO search and replace from command line
Background
I was to search and replace inside a simple batch-script and wanted a search and replace tool from the command line.
After searching I didn't find what I was looking for and compiled this simple tool.
ssr.exe (Win32-Command-Line-Tool)
Example
ssr c:\\temp\\= \\=\t test.txt
- Deletes the string c:\temp\ and replaces \ (backslash) with TAB
ssr "ServerHost=Value1"="ServerHost=Value2" config_file.ini
- Use above command to replace values in a config file
ssr -0 \x01=\x20 test.txt >test_space.txt
- Replace hex 00 with spaces in a textfile (-0 or --zero)
ssr -m="....[05]00 {8}....[05]00.*" -h=X,Y,Z \s08=, \s07=, grid.txt -o=grid_500m.csv
- Use above command to reduce huge coordinate grid file (grid in 100m) to grid in 500m CC.
Grid line format:
1234567 1234567 123.45
ssr search.txt=replace.txt test.txt
- Replaces the content of search.txt with the content of replace.txt in test.txt (if search.txt and replace.txt exists)
ssr -l -r "\s*([^ ])\s*\e\s*([^ ]*)\s*"="$1\e$2" test.txt
- Removes whitespace around Name = Value pairs in test.txt
Download / Install
- get SSR
ssr.zip
a 32-bit windows-command-line-application
- Extract the ssr.exe (1 file) place it whereever (preferable in path) and run (from command line)...
- Install ssr with chocolatey package manager:
choco install ssr -s http://chocolatey.commercior.com/chocolatey
- Update ssr with:
choco upgrade ssr -s http://chocolatey.commercior.com/chocolatey
Versions / History
- 2022-jan-24, version 1.32
- -latin1 flag: convert utf8 to latin1
- 2020-sep-04, version 1.3
- -filter flag: return only rows matching filter string
- 2019-dec-16, version 1.28
- new --mysql flag: escape ", tab and newline
- 2018-okt-12, version 1.24
- new -uf (--use-file) flag, previous version always tried to find a file with content of search or replace
- 2017-dec-30, version 1.23
- documented -rd and -sort flag
- 2017-dec-05, version 1.22
- -k flag didn't work correct and description was updated
- 2017-feb-20, version 1.20
- if search (or replace) is a filname, that content is not escaped by \t etc.
- 2016-jun-30, version 1.19
- fix to use $search$replace$ pairs for shells that do not like the equal sign
- 2014-nov-01, version 1.17
- small bug-fix
- 2013-sep-03, version 1.15
- support for \q as " (quote)
- 2013-maj-31, version 1.13
- added support to replace hex00 in textfiles
- 2013, version 1.11
- Some buggfixes published
- 2010-mar-05, version 1.6
- Support for regular expresion substitutions
- 2010-feb-22, version 1.5
- Support for large search and replace statements
- 2009-nov-05, version 1.4
- Buggfix, parsing correct filename from commandline
- 2009-oct-21, version 1.3
- Line-By-Line function for huge files.
- 2009-aug-03, version 1.0
- Implemented
Published
This tool is published in the softpedia catalogue:
softpedia.com/get/System/File-Management/SSR-Simple-Search-Replace.shtml
More info
More info/questions from:
Subject: SSR
Keywords: ssr,search,replace,simple,tool,command,line,cmdline,windows,text,textfile