Hi Didier, I think you'll need to use "$name" in quotes if there are leading, trailing or intermediate spaces in the filename. On Tue, Nov 21, 2023 at 07:59:23PM +0100, Didier Spaier wrote: > 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. > -- Joel Roth -- 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.