Trim multiple spaces with sed into a normal string.

To trim multiple spaces from a sentence and turn it back into properly readable text, use this sed syntax. sed ‘s/ \+/ /g’sed ‘s/ \+/ /g’ This is an example. echo "Hello, this sentence has multiple spaces in it and needs fixing." Hello, this sentence has multiple spaces in it and needs fixing.echo "Hello, this … Read more

How to replace spaces in file or directory names with hyphens or underscores with the Linux shell.

This command will take all files and directories in a folder and replace all of the spaces in their names with hyphens. This could be a very useful command when you want the files to have sensible filenames. john@adeptus-mechanicus ~ $ ls -hula | perl -e ‘rename $_, s/\s+/-/gr for (<*>)’john@adeptus-mechanicus ~ $ ls -hula … Read more