Cannot cat file which has space in name in linux
I believe there's a simple fix but cannot debug it out.
I have file called "file name with space
"
How do I cat
this file from Linux bash ?
linux bash cat
migrated from stackoverflow.com Jun 12 '13 at 20:14
This question came from our site for professional and enthusiast programmers.
|
show 1 more comment
I believe there's a simple fix but cannot debug it out.
I have file called "file name with space
"
How do I cat
this file from Linux bash ?
linux bash cat
migrated from stackoverflow.com Jun 12 '13 at 20:14
This question came from our site for professional and enthusiast programmers.
2
cat "file name with space"
orcat file name with space
– ctn
Jun 12 '13 at 18:22
2
cat "file with space"
doesn't work!? Good luck.
– shellter
Jun 12 '13 at 18:22
Sure: name your filefile_name_with_underscore
...
– H2CO3
Jun 12 '13 at 18:27
@H2CO3 Why if it works if everythin is implemented well?
– glglgl
Jun 12 '13 at 18:34
@glglgl Safe, convenient, cross-platform and idiomatic.
– H2CO3
Jun 12 '13 at 18:35
|
show 1 more comment
I believe there's a simple fix but cannot debug it out.
I have file called "file name with space
"
How do I cat
this file from Linux bash ?
linux bash cat
I believe there's a simple fix but cannot debug it out.
I have file called "file name with space
"
How do I cat
this file from Linux bash ?
linux bash cat
linux bash cat
asked Jun 12 '13 at 18:21
MaulzeyMaulzey
138117
138117
migrated from stackoverflow.com Jun 12 '13 at 20:14
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Jun 12 '13 at 20:14
This question came from our site for professional and enthusiast programmers.
2
cat "file name with space"
orcat file name with space
– ctn
Jun 12 '13 at 18:22
2
cat "file with space"
doesn't work!? Good luck.
– shellter
Jun 12 '13 at 18:22
Sure: name your filefile_name_with_underscore
...
– H2CO3
Jun 12 '13 at 18:27
@H2CO3 Why if it works if everythin is implemented well?
– glglgl
Jun 12 '13 at 18:34
@glglgl Safe, convenient, cross-platform and idiomatic.
– H2CO3
Jun 12 '13 at 18:35
|
show 1 more comment
2
cat "file name with space"
orcat file name with space
– ctn
Jun 12 '13 at 18:22
2
cat "file with space"
doesn't work!? Good luck.
– shellter
Jun 12 '13 at 18:22
Sure: name your filefile_name_with_underscore
...
– H2CO3
Jun 12 '13 at 18:27
@H2CO3 Why if it works if everythin is implemented well?
– glglgl
Jun 12 '13 at 18:34
@glglgl Safe, convenient, cross-platform and idiomatic.
– H2CO3
Jun 12 '13 at 18:35
2
2
cat "file name with space"
or cat file name with space
– ctn
Jun 12 '13 at 18:22
cat "file name with space"
or cat file name with space
– ctn
Jun 12 '13 at 18:22
2
2
cat "file with space"
doesn't work!? Good luck.– shellter
Jun 12 '13 at 18:22
cat "file with space"
doesn't work!? Good luck.– shellter
Jun 12 '13 at 18:22
Sure: name your file
file_name_with_underscore
...– H2CO3
Jun 12 '13 at 18:27
Sure: name your file
file_name_with_underscore
...– H2CO3
Jun 12 '13 at 18:27
@H2CO3 Why if it works if everythin is implemented well?
– glglgl
Jun 12 '13 at 18:34
@H2CO3 Why if it works if everythin is implemented well?
– glglgl
Jun 12 '13 at 18:34
@glglgl Safe, convenient, cross-platform and idiomatic.
– H2CO3
Jun 12 '13 at 18:35
@glglgl Safe, convenient, cross-platform and idiomatic.
– H2CO3
Jun 12 '13 at 18:35
|
show 1 more comment
5 Answers
5
active
oldest
votes
Does putting quotation marks around the name not work?
cat "file name with space"
add a comment |
A third option would be
cat 'file name with space'
where the file name may contain everything but the '
.
If it does, such as file n'ame
, replace every '
with '''
:
cat 'file n'''ame'
add a comment |
Use the escape character '' like this
cat file name with space
add a comment |
Enclosing the file in double quotes should work i.e.
cat "file name with space"
add a comment |
I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:
tail File.basename.Job With Spaces.log
becomes...
tail "File.basename.Job*With*Spaces.log"
I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.
1
This is WRONG. Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say). But your answer will not work!!
– Scott
Feb 16 '17 at 22:26
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f606874%2fcannot-cat-file-which-has-space-in-name-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Does putting quotation marks around the name not work?
cat "file name with space"
add a comment |
Does putting quotation marks around the name not work?
cat "file name with space"
add a comment |
Does putting quotation marks around the name not work?
cat "file name with space"
Does putting quotation marks around the name not work?
cat "file name with space"
answered Jun 12 '13 at 18:23
Phil PerryPhil Perry
21916
21916
add a comment |
add a comment |
A third option would be
cat 'file name with space'
where the file name may contain everything but the '
.
If it does, such as file n'ame
, replace every '
with '''
:
cat 'file n'''ame'
add a comment |
A third option would be
cat 'file name with space'
where the file name may contain everything but the '
.
If it does, such as file n'ame
, replace every '
with '''
:
cat 'file n'''ame'
add a comment |
A third option would be
cat 'file name with space'
where the file name may contain everything but the '
.
If it does, such as file n'ame
, replace every '
with '''
:
cat 'file n'''ame'
A third option would be
cat 'file name with space'
where the file name may contain everything but the '
.
If it does, such as file n'ame
, replace every '
with '''
:
cat 'file n'''ame'
answered Jun 12 '13 at 18:36
glglglglglgl
1,285822
1,285822
add a comment |
add a comment |
Use the escape character '' like this
cat file name with space
add a comment |
Use the escape character '' like this
cat file name with space
add a comment |
Use the escape character '' like this
cat file name with space
Use the escape character '' like this
cat file name with space
answered Jun 12 '13 at 18:25
scarecrowscarecrow
1546
1546
add a comment |
add a comment |
Enclosing the file in double quotes should work i.e.
cat "file name with space"
add a comment |
Enclosing the file in double quotes should work i.e.
cat "file name with space"
add a comment |
Enclosing the file in double quotes should work i.e.
cat "file name with space"
Enclosing the file in double quotes should work i.e.
cat "file name with space"
answered Jun 12 '13 at 18:23
Afsal
add a comment |
add a comment |
I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:
tail File.basename.Job With Spaces.log
becomes...
tail "File.basename.Job*With*Spaces.log"
I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.
1
This is WRONG. Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say). But your answer will not work!!
– Scott
Feb 16 '17 at 22:26
add a comment |
I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:
tail File.basename.Job With Spaces.log
becomes...
tail "File.basename.Job*With*Spaces.log"
I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.
1
This is WRONG. Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say). But your answer will not work!!
– Scott
Feb 16 '17 at 22:26
add a comment |
I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:
tail File.basename.Job With Spaces.log
becomes...
tail "File.basename.Job*With*Spaces.log"
I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.
I have run into this problem on Linux and in Cygwin. The one thing I found that works is to enclose the name in double-quotes and to replace non-traditional characters with asterisks. For example:
tail File.basename.Job With Spaces.log
becomes...
tail "File.basename.Job*With*Spaces.log"
I tried escaping the spaces with backslashes, whether unprotected, protected with double-quotes, or protected with single-quotes, and in all cases tail parsed the names at the spaces as though unprotected.
answered Feb 16 '17 at 20:52
Scot HarkinsScot Harkins
11
11
1
This is WRONG. Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say). But your answer will not work!!
– Scott
Feb 16 '17 at 22:26
add a comment |
1
This is WRONG. Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say). But your answer will not work!!
– Scott
Feb 16 '17 at 22:26
1
1
This is WRONG. Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say). But your answer will not work!!
– Scott
Feb 16 '17 at 22:26
This is WRONG. Three (slightly) different perfectly good (correct) answers have already been given; if you have a problem with them, try again (and make sure you do what they say). But your answer will not work!!
– Scott
Feb 16 '17 at 22:26
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f606874%2fcannot-cat-file-which-has-space-in-name-in-linux%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
cat "file name with space"
orcat file name with space
– ctn
Jun 12 '13 at 18:22
2
cat "file with space"
doesn't work!? Good luck.– shellter
Jun 12 '13 at 18:22
Sure: name your file
file_name_with_underscore
...– H2CO3
Jun 12 '13 at 18:27
@H2CO3 Why if it works if everythin is implemented well?
– glglgl
Jun 12 '13 at 18:34
@glglgl Safe, convenient, cross-platform and idiomatic.
– H2CO3
Jun 12 '13 at 18:35