? appended to filename while copying from a ssh
Clash Royale CLAN TAG#URR8PPP
I am using the command cp error.log error$HOSTNAME.log
the command works properly while running it separately in a server, but if it is run as script which uses ssh I am getting a ?
appended to the filename. In the script I am copying an error log locally using ssh
from other server and in the name of arerro$HOSTNAME.log
but this copies as arerror$HOSTNAME.log?
shell-script filenames cp newlines
add a comment |
I am using the command cp error.log error$HOSTNAME.log
the command works properly while running it separately in a server, but if it is run as script which uses ssh I am getting a ?
appended to the filename. In the script I am copying an error log locally using ssh
from other server and in the name of arerro$HOSTNAME.log
but this copies as arerror$HOSTNAME.log?
shell-script filenames cp newlines
Tryscp
instead ofssh
andcp
– Milind Dumbare
Mar 16 '15 at 14:36
2
Usedos2unix
on your script. And is it reallyerror
one place, thenarerro
, thenarerror
?! Details like this can matter a lot.
– wurtel
Mar 16 '15 at 15:39
add a comment |
I am using the command cp error.log error$HOSTNAME.log
the command works properly while running it separately in a server, but if it is run as script which uses ssh I am getting a ?
appended to the filename. In the script I am copying an error log locally using ssh
from other server and in the name of arerro$HOSTNAME.log
but this copies as arerror$HOSTNAME.log?
shell-script filenames cp newlines
I am using the command cp error.log error$HOSTNAME.log
the command works properly while running it separately in a server, but if it is run as script which uses ssh I am getting a ?
appended to the filename. In the script I am copying an error log locally using ssh
from other server and in the name of arerro$HOSTNAME.log
but this copies as arerror$HOSTNAME.log?
shell-script filenames cp newlines
shell-script filenames cp newlines
edited Mar 17 '15 at 0:54
Gilles
542k12810991616
542k12810991616
asked Mar 16 '15 at 14:22
Hussain KajaHussain Kaja
62
62
Tryscp
instead ofssh
andcp
– Milind Dumbare
Mar 16 '15 at 14:36
2
Usedos2unix
on your script. And is it reallyerror
one place, thenarerro
, thenarerror
?! Details like this can matter a lot.
– wurtel
Mar 16 '15 at 15:39
add a comment |
Tryscp
instead ofssh
andcp
– Milind Dumbare
Mar 16 '15 at 14:36
2
Usedos2unix
on your script. And is it reallyerror
one place, thenarerro
, thenarerror
?! Details like this can matter a lot.
– wurtel
Mar 16 '15 at 15:39
Try
scp
instead of ssh
and cp
– Milind Dumbare
Mar 16 '15 at 14:36
Try
scp
instead of ssh
and cp
– Milind Dumbare
Mar 16 '15 at 14:36
2
2
Use
dos2unix
on your script. And is it really error
one place, then arerro
, then arerror
?! Details like this can matter a lot.– wurtel
Mar 16 '15 at 15:39
Use
dos2unix
on your script. And is it really error
one place, then arerro
, then arerror
?! Details like this can matter a lot.– wurtel
Mar 16 '15 at 15:39
add a comment |
1 Answer
1
active
oldest
votes
It's highly likely that the file name does not in fact contain a question mark. Rather, the ls
command displays this instead of a non-printable character. Given that this character comes at the end of a file name which you specified in your script, it's probably a carriage return.
Why would you have a carriage return in your script? Because you edited it in a Windows editor. Windows represents newlines with the two-character sequence CR, LF (carriage return, line feed), whereas Unix uses just the LF character. So from Unix's perspective your script contains a line on which the last character is the ordinary character CR.
Either edit your script with a Unix editor, or use a Windows editor that allows you to save with Unix line endings.
To fix the files that you've already created, you can use the following command:
cr=$(printf 'r')
find . -name "*$cr" -exec sh -c 'for x do mv "$x" "$x%."; done' _ +
Thanks alot Gilles!! I will try to use a unix editor and will update the result.
– Hussain Kaja
Mar 17 '15 at 18:14
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f190500%2fappended-to-filename-while-copying-from-a-ssh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's highly likely that the file name does not in fact contain a question mark. Rather, the ls
command displays this instead of a non-printable character. Given that this character comes at the end of a file name which you specified in your script, it's probably a carriage return.
Why would you have a carriage return in your script? Because you edited it in a Windows editor. Windows represents newlines with the two-character sequence CR, LF (carriage return, line feed), whereas Unix uses just the LF character. So from Unix's perspective your script contains a line on which the last character is the ordinary character CR.
Either edit your script with a Unix editor, or use a Windows editor that allows you to save with Unix line endings.
To fix the files that you've already created, you can use the following command:
cr=$(printf 'r')
find . -name "*$cr" -exec sh -c 'for x do mv "$x" "$x%."; done' _ +
Thanks alot Gilles!! I will try to use a unix editor and will update the result.
– Hussain Kaja
Mar 17 '15 at 18:14
add a comment |
It's highly likely that the file name does not in fact contain a question mark. Rather, the ls
command displays this instead of a non-printable character. Given that this character comes at the end of a file name which you specified in your script, it's probably a carriage return.
Why would you have a carriage return in your script? Because you edited it in a Windows editor. Windows represents newlines with the two-character sequence CR, LF (carriage return, line feed), whereas Unix uses just the LF character. So from Unix's perspective your script contains a line on which the last character is the ordinary character CR.
Either edit your script with a Unix editor, or use a Windows editor that allows you to save with Unix line endings.
To fix the files that you've already created, you can use the following command:
cr=$(printf 'r')
find . -name "*$cr" -exec sh -c 'for x do mv "$x" "$x%."; done' _ +
Thanks alot Gilles!! I will try to use a unix editor and will update the result.
– Hussain Kaja
Mar 17 '15 at 18:14
add a comment |
It's highly likely that the file name does not in fact contain a question mark. Rather, the ls
command displays this instead of a non-printable character. Given that this character comes at the end of a file name which you specified in your script, it's probably a carriage return.
Why would you have a carriage return in your script? Because you edited it in a Windows editor. Windows represents newlines with the two-character sequence CR, LF (carriage return, line feed), whereas Unix uses just the LF character. So from Unix's perspective your script contains a line on which the last character is the ordinary character CR.
Either edit your script with a Unix editor, or use a Windows editor that allows you to save with Unix line endings.
To fix the files that you've already created, you can use the following command:
cr=$(printf 'r')
find . -name "*$cr" -exec sh -c 'for x do mv "$x" "$x%."; done' _ +
It's highly likely that the file name does not in fact contain a question mark. Rather, the ls
command displays this instead of a non-printable character. Given that this character comes at the end of a file name which you specified in your script, it's probably a carriage return.
Why would you have a carriage return in your script? Because you edited it in a Windows editor. Windows represents newlines with the two-character sequence CR, LF (carriage return, line feed), whereas Unix uses just the LF character. So from Unix's perspective your script contains a line on which the last character is the ordinary character CR.
Either edit your script with a Unix editor, or use a Windows editor that allows you to save with Unix line endings.
To fix the files that you've already created, you can use the following command:
cr=$(printf 'r')
find . -name "*$cr" -exec sh -c 'for x do mv "$x" "$x%."; done' _ +
answered Mar 17 '15 at 0:54
GillesGilles
542k12810991616
542k12810991616
Thanks alot Gilles!! I will try to use a unix editor and will update the result.
– Hussain Kaja
Mar 17 '15 at 18:14
add a comment |
Thanks alot Gilles!! I will try to use a unix editor and will update the result.
– Hussain Kaja
Mar 17 '15 at 18:14
Thanks alot Gilles!! I will try to use a unix editor and will update the result.
– Hussain Kaja
Mar 17 '15 at 18:14
Thanks alot Gilles!! I will try to use a unix editor and will update the result.
– Hussain Kaja
Mar 17 '15 at 18:14
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f190500%2fappended-to-filename-while-copying-from-a-ssh%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
Try
scp
instead ofssh
andcp
– Milind Dumbare
Mar 16 '15 at 14:36
2
Use
dos2unix
on your script. And is it reallyerror
one place, thenarerro
, thenarerror
?! Details like this can matter a lot.– wurtel
Mar 16 '15 at 15:39