How to Manipulate Filenames Having Spaces and Special Characters in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

5 Responses

  1. alimp5 says:

    Thanks a lot, really great article with good practical examples..

  2. Kishore says:

    Regarding the terminal argument ” touch *12.txt ” may open up more than one file if you have a file named a12.txt , b12.txt etc in a text editor like Geany or the first file in alphabetical order in Nano .

  3. Naveen says:

    We can eliminate this issue by passing the file name is single quote to solve the special characters present in the file.

    Eg: touch ‘₹@@%%@’

  4. inukaze says:

    Hi there i have a lot of files with [!] in their namefiles , i need move just that files inside another sub-folder , i try with

    for file in $(ls | grep -e “.[!]]” | awk ‘NF { print “\””$0″\””}’); do mv -f “$PWD/$file” “$PWD/Folder001/” ; done

    but is imposible , because bash in “do mv -f “$PWD/$file”
    reads the “This is an example of large filename.ext” like

    This -> File1
    is -> File2
    an -> File 3
    example -> File 4
    of -> File 5
    large -> File 6
    filename.ext -> File 7

    How i can use “mv” for large filename with special characters like [!](EJU) to another folder ???

  5. MaxIo_Yu says:

    it’s easy to create such files, “” will resolve all the situation, but it’s hard to process them in your script or command.
    the most ugly file name I have seen it’s “xxx “, since when i list it in terminal, I cannot know how many spaces the name inlcuded. but if it’s in script, it will have no problem to get the name through API

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 300K+ Linux Users
  1. 177,942
  2. 8,310
  3. 37,548

Are you subscribed?