f2
f2 copied to clipboard
Fail to replace with RE
version: F2 version v1.7.2
, installed from apt
system: Debian 12 bookworm
files:
00.a.txt
01.b.txt
02.c.txt
03.d.txt
04.e.txt
05.f.txt
cmd:
f2 -f "0(\d\)\." -r "0\$1_"
result:
+----------+--------+--------+
| INPUT | OUTPUT | STATUS |
+----------+--------+--------+
| 00.a.txt | 0a.txt | ok |
| 01.b.txt | 0b.txt | ok |
| 02.c.txt | 0c.txt | ok |
| 03.d.txt | 0d.txt | ok |
| 04.e.txt | 0e.txt | ok |
| 05.f.txt | 0f.txt | ok |
+----------+--------+--------+
INFO Use the -x or --exec flag to apply the above changes
expected:
+----------+----------+--------+
| INPUT | OUTPUT | STATUS |
+----------+----------+--------+
| 00.a.txt | 00_a.txt | ok |
| 01.b.txt | 01_b.txt | ok |
| 02.c.txt | 02_c.txt | ok |
| 03.d.txt | 03_d.txt | ok |
| 04.e.txt | 04_e.txt | ok |
| 05.f.txt | 05_f.txt | ok |
+----------+--------+--------+
INFO Use the -x or --exec flag to apply the above changes
Hi @hellyguo ,
Thanks for reporting this. It's not a bug in F2 but due to the way Go interprets capture variables. You have to do this to get the correct result:
f2 -f "0(\d)\." -r '0${1}_'
┌──────────────────────────────┐
| ORIGINAL | RENAMED | STATUS |
| **************************** |
| 00.a.txt | 00_a.txt | ok |
| 01.b.txt | 01_b.txt | ok |
| 02.c.txt | 02_c.txt | ok |
| 03.d.txt | 03_d.txt | ok |
| 04.e.txt | 04_e.txt | ok |
| 05.f.txt | 05_f.txt | ok |
└──────────────────────────────┘
I will keep this issue open so I remember to note this behaviour in the documentation.
thx! I know now.
sorry, I reopen again.