Snippets of Computational Biology, Bioinformatics, Productivity and the like
Tuesday, 13 April 2010
Perl One Liner: Remove whitespace from file name
It is often a pain to have spaces in file names when working at the command line, so remove them, or at least replace then with underscores. In this case it works on all bed files in the current directory.
ls *.bed |perl -ne 'use File::Copy;chomp;$old=$_;s/\s+/_/g;move($old,$_);'
You could replace the ls with a find for more control.