//View Tip #670
Similar Tips
» Split a long URL
» Uppercase to lowercase with tr
» Check memory and swap from command line

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
The command below can be used to convert a string into a valid filename. Uppercase letters are converted to lowercase, all difficult characters are removed and spaces are changed to underscores.

echo "#cLEa:n (%FILE%)" | tr [:upper:] [:lower:] | tr -d "[]()&~@#%^&*()_+=;:,\$" | tr " " "_"

This example will output 'clean_file'.


View Comments »




Comments 

Add your comment

Comments are currently disabled
You can do similar things with the detox utility
Posted 2009-04-10 13:00:16
multics
Pretty nice and usefull command, thx for publishing.
Posted 2009-04-11 19:25:14

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit