-
Find and rename files with regexp
find . -type f -name '*.stories.tsx' -execdir rename -v 's/(.*)\.stories\.tsx$/component\.stories\.tsx/' {} \;;
-
Redirect port:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000
-
Rename all occurance of text:
git grep -l 'original_text' | xargs sed -i 's/original_text/new_text/g'
-
Replace a text occurrence with / in multiple files
cur='@quadlobe/spt' rep='spt' git grep -l "$cur" | xargs sed -i -e "s%$cur%$rep%g"
-
Rename files in a directory
files=$(find . -iname "*.js") for file in $files; do mv "$file" "${file%.js}.ts" done
- Apply macro on lines matching pattern
:g/pattern/norm! @a
- Apply macro on line 5 to 10
:5,10norm! @a
- Apply macro on highlights lines (V)
:'<,'>norm! @a