All Projects → piranha → Goreplace

piranha / Goreplace

Licence: isc
command line tool for search and replace

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Goreplace

Linuxtool
Linux下常用工具、命令介绍,跟我学Linux
Stars: ✭ 314 (+91.46%)
Mutual labels:  grep
Vim Grepper
👾 Helps you win at grep.
Stars: ✭ 1,030 (+528.05%)
Mutual labels:  grep
Command Line Text Processing
⚡ From finding text to search and replace, from sorting to beautifying text and more 🎨
Stars: ✭ 9,771 (+5857.93%)
Mutual labels:  grep
Blush
Grep with colours
Stars: ✭ 410 (+150%)
Mutual labels:  grep
Sakura
SAKURA Editor (Japanese text editor for MS Windows)
Stars: ✭ 689 (+320.12%)
Mutual labels:  grep
Rare
Fast, realtime regex-extraction, and aggregation into common formats such as histograms, numerical summaries, tables, and more!
Stars: ✭ 76 (-53.66%)
Mutual labels:  grep
Rg.el
Emacs search tool based on ripgrep
Stars: ✭ 277 (+68.9%)
Mutual labels:  grep
Grepbugs
A regex based source code scanner.
Stars: ✭ 118 (-28.05%)
Mutual labels:  grep
Ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Stars: ✭ 28,564 (+17317.07%)
Mutual labels:  grep
Bingrep
like ~~grep~~ UBER, but for binaries
Stars: ✭ 1,395 (+750.61%)
Mutual labels:  grep
Bsed
Simple SQL-like syntax on top of Perl text processing.
Stars: ✭ 414 (+152.44%)
Mutual labels:  grep
Ugrep
🔍NEW ugrep v3.1: ultra fast grep with interactive query UI and fuzzy search: search file systems, source code, text, binary files, archives (cpio/tar/pax/zip), compressed files (gz/Z/bz2/lzma/xz/lz4), documents and more. A faster, user-friendly and compatible grep replacement.
Stars: ✭ 626 (+281.71%)
Mutual labels:  grep
Wheel
Quick navigation framework for Vim and Neovim : buffer groups, mru, locate, find, grep, outline, yank, ...
Stars: ✭ 94 (-42.68%)
Mutual labels:  grep
Ack3
ack is a grep-like search tool optimized for source code.
Stars: ✭ 330 (+101.22%)
Mutual labels:  grep
Ucg
UniversalCodeGrep (ucg) is an extremely fast grep-like tool specialized for searching large bodies of source code.
Stars: ✭ 117 (-28.66%)
Mutual labels:  grep
Teip
Select partial standard input and replace with the result of another command efficiently
Stars: ✭ 280 (+70.73%)
Mutual labels:  grep
Comb
Interactive code auditing and grep tool in Emacs Lisp
Stars: ✭ 58 (-64.63%)
Mutual labels:  grep
Dategrep
print lines matching a time range
Stars: ✭ 159 (-3.05%)
Mutual labels:  grep
Ack2
**ack 2 is no longer being maintained. ack 3 is the latest version.**
Stars: ✭ 1,504 (+817.07%)
Mutual labels:  grep
Bash Oneliner
A collection of handy Bash One-Liners and terminal tricks for data processing and Linux system maintenance.
Stars: ✭ 1,359 (+728.66%)
Mutual labels:  grep

Go Replace

Go Replace (gr) is a simple utility which can be used as replacement for grep + sed combination in one of most popular cases - find files, which contain something, possibly replace this with something else. Main points:

  • Reads .hgignore/.gitignore to skip files
  • Skips binaries
  • Familiar PCRE-like regexp syntax
  • Can perform replacements
  • Fast

Bonus:

  • Can search in file names with -f (i.e. a simple alternative to find)

Build Status

Releases and changelog

Why

Why do thing which is done by grep, find, and sed? Well, for one - I grew tired of typing long commands with pipes and ugly syntax. You want to search? Use grep. Replace? Use find and sed! Different syntax, context switching, etc. Switching from searching to replacing with gr is 'up one item in history and add a replacement string', much simpler!

Besides, it's also faster than grep! Hard to believe, and it's a bit of cheating - but gr by default ignores everything you have in your .hgignore and .gitignore files, skipping binary files and compiled bytecodes (which you usually don't want to touch anyway).

This is my reason to use it - less latency doing task I'm doing often.

Installation

Just download a suitable binary from release page. Put this file in your $PATH and rename it to gr to have easier access.

Building from source

You can also install it from source, if that's your thing:

go get github.com/piranha/goreplace

And you should be done. You have to have $GOPATH set for this to work (go will put sources and generated binary there). Add -u flag there to update your gr.

I prefer name gr to goreplace, so I link gr somewhere in my path (usually in ~/bin) to $GOPATH/bin/goreplace. NOTE: if you use oh-my-zsh, it aliases gr to git remote, so you either should use another name (I propose gor) or remove gr alias:

mkdir -p ~/.oh-my-zsh/custom && echo "unalias gr" >> ~/.oh-my-zsh/custom/goreplace.zsh

Usage

Usage is pretty simple, you can just run gr to see help on options. Basically you just supply a regexp (or a simple string - it's a regexp always as well) as an argument and gr will search for it in all files starting from the current directory, just like this:

gr somestring

Some directories and files can be ignored by default (gr is looking for your .hgignore/.gitignore in parent directories), just run gr without any arguments to see help message - it contains information about them.

And to replace:

gr somestring -r replacement

It's performed in place and no backups are made (not that you need them, right? You're using version control, aren't you?). Regular expression submatches supported via $1 syntax - see re2 documentation for more information about syntax and capabilities.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].