2015-12-19 21:35:19 +00:00
|
|
|
---
|
|
|
|
title: Perl-pie
|
|
|
|
category: Development
|
|
|
|
---
|
|
|
|
|
2023-03-14 01:52:21 +00:00
|
|
|
### About
|
|
|
|
{: .-intro}
|
|
|
|
|
|
|
|
Use `perl` to search and replace across many files.
|
|
|
|
|
2015-12-19 21:35:19 +00:00
|
|
|
### Search and replace
|
|
|
|
|
|
|
|
```sh
|
|
|
|
perl -p -i -e 's/hello/hola/g' *.txt
|
|
|
|
```
|
|
|
|
|
|
|
|
### Back-referencing
|
|
|
|
|
|
|
|
Use `\1` et al.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# '@include align-items(center);' => 'align-items: center;'
|
|
|
|
perl -p -i -e "s/\@include (align-items)\((.*)\);/\1: \2;/g"
|
|
|
|
```
|