Techolac - Computer Technology News
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
Techolac - Computer Technology News
No Result
View All Result
Home Linux

How to Read a Filename with Spaces in Linux

by Editorial Staff
December 31, 2020
in Linux
Reading Time: 2 mins read

It’s not very common in Linux to handle filename with spaces but sometimes files copied or mounted from windows would end up with spaces.

While it is not recommended to have file names with spaces, let discuss how to manage filename with spaces in a Linux system.

We will cover how to create, read and copy a file which has spaces in their filename.

1) Creating file names with spaces

To create files with spaces in file names, run the command as shown

$ touch'firstname secondname'

For example, to create a file called ‘linoxide docs‘ use the syntax below

$ touch 'linoxide docs'

Output

create and view files with spaces

If you want to view such a file with space in the file name, use the same principle of enclosing the file names inside the quotation marks.

2) Read a File with spaces in filename

You can use ‘cat’ command or open the document using your preferred text editor such as vim, nano or gedit.

$  cat 'linoxide docs'

Alternatively, you can use the syntax below

$ cat file name with spaces

Let’s add some text to the 'linoxide docs' file

$ echo "Hello guys! Welcome to Linoxide" >> 'linoxide docs'

To view the file execute the command below

$ cat linoxide docs

Output

cat file names with spaces

3) Creating directory names with spaces

To create directory names with space in between use the syntax below

$ mkdir firstname secondname

Please note the space after the backslash

For example, to create a directory called ‘linoxide files‘ run

$ mkdir linoxide files

Output

create directory names with spaces

4) Navigating to a directory with spaces in the directory name

To navigate to a directory with spaces in its directory name, use the syntax below

$ cd  directory name

To navigate to the directory ‘linoxide files’ execute the command below

$ cd linoxide files

cd into directory with directory name with spaces

5) Copying a directory with spaces in the directory name

To copy a directory with spaces in its directory name to a different location use the syntax below

$ cp -R directory name  /destination/path

OR

$ cp -R 'directory name'  /destination/path/

For  example to copy 'linoxide files'  to /home/james path execute

$ cp -R 'linoxide files'  /home/james/

copy directory with spaces in directory name

or

$ cp -R linoxide files /home/james

copy directory with spaces in directory name-2

Hope this article explained well on how to manage filename with spaces. Thanks for taking the time to read this article and please leave your comments.

See also  Ubuntu dig command not found - How to install dig on Ubuntu

 

Related Posts

Top Commands to Check the Running Processes in Linux
Linux

Top Commands to Check the Running Processes in Linux

May 27, 2022
4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error
Linux

4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error

March 30, 2022
How Common Signals are Used in Kubernetes Pod Management
Linux

How Common Signals are Used in Kubernetes Pod Management

November 20, 2021

Leave a Reply Cancel reply

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

30 Subscene Alternatives To Watch Movies And TV Shows Online

30 Subscene Alternatives To Watch Movies And TV Shows Online

August 12, 2022
asura hosting

Top 15 Best Asura Hosting Alternatives In 2022

August 12, 2022
How to Recognize an Outstanding Developer in an Interview

How to Recognize an Outstanding Developer in an Interview

August 12, 2022
30 1Movies Alternatives To Watch Movies And TV Shows Online

30 1Movies Alternatives To Watch Movies And TV Shows Online

August 11, 2022
Instagram followers tracker

Top 16 Instagram Followers Trackers In 2022

August 11, 2022
  • DashTech
  • TechDaddy
  • Terms and Conditions
  • Disclaimer
  • Write for us

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

Go to mobile version