Showing posts with label white space. Show all posts
Showing posts with label white space. Show all posts

Friday, 14 May 2010

Bash: Remove spaces from filename

Some people use spaces in file names, silly I know. Remove them!
find .|while read file;do mv "${file}" $(echo "${file}" | perl -ne 's/ /_/g;print;');done

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.