Posted By

licensetoil on 01/28/12


whitespace unix remove files administration perl rename

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Batch remove whitespace in all the files in directory and replace with a dash "-"

 / Published in: Bash


Add this to your .profile or .bashrc file, source the file, navigate to the directory and call "rmwhitespace"

Based on:

  1. alias rm_whitespace="for F in * ; do NF=\`echo \$F | perl -lne \"s/ /-/g; s/\_/-/g; s/[,']//g; s/[-]+/-/g; print\"\` ; mv \"\$F\" \"\$NF\" ; done"

Report this snippet  

You need to login to post a comment.