我需要重命名文件的帮助:
$ cat q.txt
Only in /aa/bb/home/sh/POC/Backup/DDL/: comp1.txt
Only in /aa/bb/home/sh/POC/Backup/DDL/: comp.txt
Only in /aa/bb/home/sh/POC/Backup/DDL/: junk.txt
Files /aa/bb/home/sh/POC/05_26_2022/DDL/test.demo/table1.txt and /aa/bb/home/sh/POC/Backup/DDL/test.demo_table1.txt differ
Only in /aa/bb/home/sh/POC/05_26_2022/DDL: test.demo_table2.txt
$ cat q.txt | awk '/^Only/ {gsub("[/:]+","/", $3); {sub(/^.*\//, "", $3);print $NF > $3".txt"} /^Files.*differ/ {sub(/^.*\//, "", $2); print $2.txt > "different.txt"}'
目前它给出的文件名带有 _
ls -lrt
27 May 27 07:02 _aa_bb_home_sh_POC_05_26_2022_DDL.txt
28 May 27 07:02 _aa_bb_home_sh_POC_Backup_DDL_.txt
27 May 27 07:04 different.txt
我需要像下面这样的o/p
ls -lrt
27 May 27 07:02 05_26_2022_DDL.txt
28 May 27 07:02 Backup_DDL.txt
27 May 27 07:04 different.txt