What does the command “rename * *.log *” do?











up vote
0
down vote

favorite












I am running Red Hat 7.3.



I typed in rename * *.log * with the hope of removing log from the names of all files.



I don't this has been happening, and in short, I think somehow files are disappearing.










share|improve this question
























  • Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look at man rename
    – George Udosen
    Dec 21 '17 at 6:30















up vote
0
down vote

favorite












I am running Red Hat 7.3.



I typed in rename * *.log * with the hope of removing log from the names of all files.



I don't this has been happening, and in short, I think somehow files are disappearing.










share|improve this question
























  • Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look at man rename
    – George Udosen
    Dec 21 '17 at 6:30













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am running Red Hat 7.3.



I typed in rename * *.log * with the hope of removing log from the names of all files.



I don't this has been happening, and in short, I think somehow files are disappearing.










share|improve this question















I am running Red Hat 7.3.



I typed in rename * *.log * with the hope of removing log from the names of all files.



I don't this has been happening, and in short, I think somehow files are disappearing.







linux rename






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 at 20:33









Rui F Ribeiro

38.3k1475126




38.3k1475126










asked Dec 21 '17 at 4:11









Stuart Wilson

1




1












  • Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look at man rename
    – George Udosen
    Dec 21 '17 at 6:30


















  • Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look at man rename
    – George Udosen
    Dec 21 '17 at 6:30
















Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look at man rename
– George Udosen
Dec 21 '17 at 6:30




Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look at man rename
– George Udosen
Dec 21 '17 at 6:30










1 Answer
1






active

oldest

votes

















up vote
2
down vote













It depends on what program rename is on your system (I can't remember for RHEL). If it's the util-linux rename, you probably renamed your first file over the second one. Here's what happens. (I'll use rename.ul for clarity here.)



With the three files a.log, b.log, and c.log if we give the command rename.ul * *.log *, the shell expands the globs and the final command that runs is:



rename.ul a.log b.log c.log a.log b.log c.log a.log b.log c.log


Now, rename takes the first two as a pattern and a replacement, and applies those to the files named by the rest of arguments. So, basically the command tells to replace a.log with b.log in the names of any of c.log a.log b.log c.log a.log b.log c.log. Only a.log matches, and it's moved over b.log, and you probably get an error message for the next a.log listed.



If your rename was the Perl rename (prename) instead, you would probably have gotten an error without anything happening, since your first filename is likely to not be a valid Perl command. prename also doesn't overwrite files by default.





With the util-linux rename, to remove .log from the file names, you'd use



$ rename.ul .log "" *.log


That would change any matches from the middle of the name too, so v.logger would turn into vger.



With the Perl rename, the command would be



$ prename 's/.log$//' *.log





share|improve this answer

















  • 1




    The second is what I observed in my test case on Ubuntu, but again OP says files are disappearing. I wonder what OP means by that!
    – George Udosen
    Dec 21 '17 at 6:32












  • @GeorgeUdosen, well, try with the util-linux rename. You might have it as rename.ul. They're different tools, Debian/Ubuntu have the Perl tool as default, but I can't find a source on what other Linuxen have behind the name rename.
    – ilkkachu
    Dec 21 '17 at 10:08











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',
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
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f412166%2fwhat-does-the-command-rename-log-do%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








up vote
2
down vote













It depends on what program rename is on your system (I can't remember for RHEL). If it's the util-linux rename, you probably renamed your first file over the second one. Here's what happens. (I'll use rename.ul for clarity here.)



With the three files a.log, b.log, and c.log if we give the command rename.ul * *.log *, the shell expands the globs and the final command that runs is:



rename.ul a.log b.log c.log a.log b.log c.log a.log b.log c.log


Now, rename takes the first two as a pattern and a replacement, and applies those to the files named by the rest of arguments. So, basically the command tells to replace a.log with b.log in the names of any of c.log a.log b.log c.log a.log b.log c.log. Only a.log matches, and it's moved over b.log, and you probably get an error message for the next a.log listed.



If your rename was the Perl rename (prename) instead, you would probably have gotten an error without anything happening, since your first filename is likely to not be a valid Perl command. prename also doesn't overwrite files by default.





With the util-linux rename, to remove .log from the file names, you'd use



$ rename.ul .log "" *.log


That would change any matches from the middle of the name too, so v.logger would turn into vger.



With the Perl rename, the command would be



$ prename 's/.log$//' *.log





share|improve this answer

















  • 1




    The second is what I observed in my test case on Ubuntu, but again OP says files are disappearing. I wonder what OP means by that!
    – George Udosen
    Dec 21 '17 at 6:32












  • @GeorgeUdosen, well, try with the util-linux rename. You might have it as rename.ul. They're different tools, Debian/Ubuntu have the Perl tool as default, but I can't find a source on what other Linuxen have behind the name rename.
    – ilkkachu
    Dec 21 '17 at 10:08















up vote
2
down vote













It depends on what program rename is on your system (I can't remember for RHEL). If it's the util-linux rename, you probably renamed your first file over the second one. Here's what happens. (I'll use rename.ul for clarity here.)



With the three files a.log, b.log, and c.log if we give the command rename.ul * *.log *, the shell expands the globs and the final command that runs is:



rename.ul a.log b.log c.log a.log b.log c.log a.log b.log c.log


Now, rename takes the first two as a pattern and a replacement, and applies those to the files named by the rest of arguments. So, basically the command tells to replace a.log with b.log in the names of any of c.log a.log b.log c.log a.log b.log c.log. Only a.log matches, and it's moved over b.log, and you probably get an error message for the next a.log listed.



If your rename was the Perl rename (prename) instead, you would probably have gotten an error without anything happening, since your first filename is likely to not be a valid Perl command. prename also doesn't overwrite files by default.





With the util-linux rename, to remove .log from the file names, you'd use



$ rename.ul .log "" *.log


That would change any matches from the middle of the name too, so v.logger would turn into vger.



With the Perl rename, the command would be



$ prename 's/.log$//' *.log





share|improve this answer

















  • 1




    The second is what I observed in my test case on Ubuntu, but again OP says files are disappearing. I wonder what OP means by that!
    – George Udosen
    Dec 21 '17 at 6:32












  • @GeorgeUdosen, well, try with the util-linux rename. You might have it as rename.ul. They're different tools, Debian/Ubuntu have the Perl tool as default, but I can't find a source on what other Linuxen have behind the name rename.
    – ilkkachu
    Dec 21 '17 at 10:08













up vote
2
down vote










up vote
2
down vote









It depends on what program rename is on your system (I can't remember for RHEL). If it's the util-linux rename, you probably renamed your first file over the second one. Here's what happens. (I'll use rename.ul for clarity here.)



With the three files a.log, b.log, and c.log if we give the command rename.ul * *.log *, the shell expands the globs and the final command that runs is:



rename.ul a.log b.log c.log a.log b.log c.log a.log b.log c.log


Now, rename takes the first two as a pattern and a replacement, and applies those to the files named by the rest of arguments. So, basically the command tells to replace a.log with b.log in the names of any of c.log a.log b.log c.log a.log b.log c.log. Only a.log matches, and it's moved over b.log, and you probably get an error message for the next a.log listed.



If your rename was the Perl rename (prename) instead, you would probably have gotten an error without anything happening, since your first filename is likely to not be a valid Perl command. prename also doesn't overwrite files by default.





With the util-linux rename, to remove .log from the file names, you'd use



$ rename.ul .log "" *.log


That would change any matches from the middle of the name too, so v.logger would turn into vger.



With the Perl rename, the command would be



$ prename 's/.log$//' *.log





share|improve this answer












It depends on what program rename is on your system (I can't remember for RHEL). If it's the util-linux rename, you probably renamed your first file over the second one. Here's what happens. (I'll use rename.ul for clarity here.)



With the three files a.log, b.log, and c.log if we give the command rename.ul * *.log *, the shell expands the globs and the final command that runs is:



rename.ul a.log b.log c.log a.log b.log c.log a.log b.log c.log


Now, rename takes the first two as a pattern and a replacement, and applies those to the files named by the rest of arguments. So, basically the command tells to replace a.log with b.log in the names of any of c.log a.log b.log c.log a.log b.log c.log. Only a.log matches, and it's moved over b.log, and you probably get an error message for the next a.log listed.



If your rename was the Perl rename (prename) instead, you would probably have gotten an error without anything happening, since your first filename is likely to not be a valid Perl command. prename also doesn't overwrite files by default.





With the util-linux rename, to remove .log from the file names, you'd use



$ rename.ul .log "" *.log


That would change any matches from the middle of the name too, so v.logger would turn into vger.



With the Perl rename, the command would be



$ prename 's/.log$//' *.log






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 21 '17 at 6:30









ilkkachu

54.1k782147




54.1k782147








  • 1




    The second is what I observed in my test case on Ubuntu, but again OP says files are disappearing. I wonder what OP means by that!
    – George Udosen
    Dec 21 '17 at 6:32












  • @GeorgeUdosen, well, try with the util-linux rename. You might have it as rename.ul. They're different tools, Debian/Ubuntu have the Perl tool as default, but I can't find a source on what other Linuxen have behind the name rename.
    – ilkkachu
    Dec 21 '17 at 10:08














  • 1




    The second is what I observed in my test case on Ubuntu, but again OP says files are disappearing. I wonder what OP means by that!
    – George Udosen
    Dec 21 '17 at 6:32












  • @GeorgeUdosen, well, try with the util-linux rename. You might have it as rename.ul. They're different tools, Debian/Ubuntu have the Perl tool as default, but I can't find a source on what other Linuxen have behind the name rename.
    – ilkkachu
    Dec 21 '17 at 10:08








1




1




The second is what I observed in my test case on Ubuntu, but again OP says files are disappearing. I wonder what OP means by that!
– George Udosen
Dec 21 '17 at 6:32






The second is what I observed in my test case on Ubuntu, but again OP says files are disappearing. I wonder what OP means by that!
– George Udosen
Dec 21 '17 at 6:32














@GeorgeUdosen, well, try with the util-linux rename. You might have it as rename.ul. They're different tools, Debian/Ubuntu have the Perl tool as default, but I can't find a source on what other Linuxen have behind the name rename.
– ilkkachu
Dec 21 '17 at 10:08




@GeorgeUdosen, well, try with the util-linux rename. You might have it as rename.ul. They're different tools, Debian/Ubuntu have the Perl tool as default, but I can't find a source on what other Linuxen have behind the name rename.
– ilkkachu
Dec 21 '17 at 10:08


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f412166%2fwhat-does-the-command-rename-log-do%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Accessing regular linux commands in Huawei's Dopra Linux

Can't connect RFCOMM socket: Host is down

Kernel panic - not syncing: Fatal Exception in Interrupt