Preview a replacement with ripgrep

Show the whole file with the replacement applied, without writing to it

rg 'old_value' --replace 'new_value' --passthru config.yaml

tool
grep15 commands
tags
grep

More grep commands

  • rg 'error' /var/log/ --stats 2>&1 | tail -5

    Show the number of matches, searched files and elapsed time

  • grep -a 'password' /proc/<pid>/mem 2>/dev/null | strings | head -20

    Treat binary data as text (-a), here to search process memory

  • grep -E '(ERROR|WARN|CRIT)' app.log | tail -50

    Show the last 50 lines that contain ERROR, WARN or CRIT

  • grep -ri 'error' /var/log/

    Find "error" in any case in all files under /var/log

  • grep -B3 -A5 'FATAL' app.log

    Print 3 lines before and 5 lines after each match

all 15 grep commands