Re: Regex for spaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rob,

Assuming that the file is named "name":
echo $name|sed 's/^[[:space:]]*//;s/[[:space:]]*$//'

Then to rename the file: mv $name $(echo $name|sed
's/^[[:space:]]*//;s/[[:space:]]*$//')
This will remove any number of leading and trailing spaces.

Cheers,
Didier
didieratslintdotfr

Le 21/11/2023 à 16:34, 'Rob Hudson' via blinux-list@xxxxxxxxxx a écrit :
> I am not good with regexes at all. They give me a headache lol. Can anyone supply me a regex that will remove any trailing spaces in front or at the end of a file name? I use the program brename:
> https://github.com/shenwei356/brename/
> I have a regex to remove double spaces, but now I need one that will knock off leading and trailing.
> Thanks for any help.

-- 
You received this message because you are subscribed to the Google Groups "blinux-list@xxxxxxxxxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blinux-list+unsubscribe@xxxxxxxxxx.





[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]