From 30e0c964a2095734b39438fca1fc80fc2bcddd24 Mon Sep 17 00:00:00 2001 From: desktop Date: Wed, 25 Oct 2023 14:47:09 +0300 Subject: [PATCH] bash : name : improve pattern matching. --- document/linux/config/bash/module/name.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/document/linux/config/bash/module/name.sh b/document/linux/config/bash/module/name.sh index 800312f..4240d2d 100644 --- a/document/linux/config/bash/module/name.sh +++ b/document/linux/config/bash/module/name.sh @@ -20,9 +20,10 @@ name() new_name=$(echo "$file" | \ sed -e "s/ /_/g" \ -e "s/[^[:alnum:]\._-]//g" \ + -e "s/_\+/_/g" -e "s/\.\+/\./g" -e "s/-\+/-/g" \ + -e "s/_-/_/g" -e "s/-_/_/g" -e "s/\.-/_/g" -e "s/-\./_/g" -e "s/\._/_/g" -e "s/_\./_/g" \ -e "s/_\+/_/g" \ - -e "s/_-_/_/g" \ - -e "s/^_\+//" + -e "s/^_//" -e "s/_$//" ) # status line.