RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

Remove or substitute space within a file name

Having a space in the file name is never a good idea. If you are in need to remove space from all file names within your current directory you can use a following command to do so:

 ls | grep " " | while read -r f; do mv -i "$f" `echo $f | tr -d ' '`; done

In case that you wish to substitute space within a file name to underscore ( or any other character ) use a following command to do so:

ls | grep " " | while read -r f; do mv "$f" `echo $f | tr ' ' '_'`; done

How it works? ls and grep will feed while loop with all files within a current working directory which contain a space in their file name. In the body of the while loop we will next execute mv command a translate it file destination with tr command. Make sure to keep -i option enabled when using mv command to avoid accidentally overwrite files.

Share this linux post:

Submit Remove or substitute space within a file name in Delicious Submit Remove or substitute space within a file name in Digg Submit Remove or substitute space within a file name in FaceBook Submit Remove or substitute space within a file name in Google Bookmarks Submit Remove or substitute space within a file name in Stumbleupon Submit Remove or substitute space within a file name in Technorati Submit Remove or substitute space within a file name in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download