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.
linux rename
add a comment |
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.
linux rename
Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look atman rename
– George Udosen
Dec 21 '17 at 6:30
add a comment |
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.
linux rename
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
linux rename
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 atman rename
– George Udosen
Dec 21 '17 at 6:30
add a comment |
Tried this command nothing happens at my end, and what do you mean by files are disappearing? Look atman 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
add a comment |
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
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-linuxrename
. You might have it asrename.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 namerename
.
– ilkkachu
Dec 21 '17 at 10:08
add a comment |
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
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-linuxrename
. You might have it asrename.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 namerename
.
– ilkkachu
Dec 21 '17 at 10:08
add a comment |
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
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-linuxrename
. You might have it asrename.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 namerename
.
– ilkkachu
Dec 21 '17 at 10:08
add a comment |
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
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
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-linuxrename
. You might have it asrename.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 namerename
.
– ilkkachu
Dec 21 '17 at 10:08
add a comment |
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-linuxrename
. You might have it asrename.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 namerename
.
– 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
add a comment |
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%2f412166%2fwhat-does-the-command-rename-log-do%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
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