Eliminating multiple-extension file names from find output
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I need to find the size of all files in /etc
with the .conf
extension. I tried to do this with find /etc -type f -name "*.conf" -exec du -chB1 +
, but find gave me .conf
files that have two or three extensions. The question is how can I filter find
output in order to get just the files with one extension, that being .conf
? Can this be achieved through find
or do I need another command ?
find filenames
New contributor
add a comment |
up vote
0
down vote
favorite
I need to find the size of all files in /etc
with the .conf
extension. I tried to do this with find /etc -type f -name "*.conf" -exec du -chB1 +
, but find gave me .conf
files that have two or three extensions. The question is how can I filter find
output in order to get just the files with one extension, that being .conf
? Can this be achieved through find
or do I need another command ?
find filenames
New contributor
What do you mean bytwo or three extensions
, can you clarify on that
– sla3k
2 days ago
How do you define an extension? What if the file name isa.b.conf
. Wherea.b
is file name and.conf
is an extension?
– Debian_yadav
2 days ago
Well, for example I wanted to find file names like this one/etc/pam.conf
, but instead the command above would give me something like this too/etc.dbus-1/system.d/org.freedesktop.bolt.conf
– george
2 days ago
What about a hidden.ltrace.conf
file for instance?
– Stéphane Chazelas
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to find the size of all files in /etc
with the .conf
extension. I tried to do this with find /etc -type f -name "*.conf" -exec du -chB1 +
, but find gave me .conf
files that have two or three extensions. The question is how can I filter find
output in order to get just the files with one extension, that being .conf
? Can this be achieved through find
or do I need another command ?
find filenames
New contributor
I need to find the size of all files in /etc
with the .conf
extension. I tried to do this with find /etc -type f -name "*.conf" -exec du -chB1 +
, but find gave me .conf
files that have two or three extensions. The question is how can I filter find
output in order to get just the files with one extension, that being .conf
? Can this be achieved through find
or do I need another command ?
find filenames
find filenames
New contributor
New contributor
edited 2 days ago
don_crissti
48.6k15129156
48.6k15129156
New contributor
asked 2 days ago
george
1
1
New contributor
New contributor
What do you mean bytwo or three extensions
, can you clarify on that
– sla3k
2 days ago
How do you define an extension? What if the file name isa.b.conf
. Wherea.b
is file name and.conf
is an extension?
– Debian_yadav
2 days ago
Well, for example I wanted to find file names like this one/etc/pam.conf
, but instead the command above would give me something like this too/etc.dbus-1/system.d/org.freedesktop.bolt.conf
– george
2 days ago
What about a hidden.ltrace.conf
file for instance?
– Stéphane Chazelas
2 days ago
add a comment |
What do you mean bytwo or three extensions
, can you clarify on that
– sla3k
2 days ago
How do you define an extension? What if the file name isa.b.conf
. Wherea.b
is file name and.conf
is an extension?
– Debian_yadav
2 days ago
Well, for example I wanted to find file names like this one/etc/pam.conf
, but instead the command above would give me something like this too/etc.dbus-1/system.d/org.freedesktop.bolt.conf
– george
2 days ago
What about a hidden.ltrace.conf
file for instance?
– Stéphane Chazelas
2 days ago
What do you mean by
two or three extensions
, can you clarify on that– sla3k
2 days ago
What do you mean by
two or three extensions
, can you clarify on that– sla3k
2 days ago
How do you define an extension? What if the file name is
a.b.conf
. Where a.b
is file name and .conf
is an extension?– Debian_yadav
2 days ago
How do you define an extension? What if the file name is
a.b.conf
. Where a.b
is file name and .conf
is an extension?– Debian_yadav
2 days ago
Well, for example I wanted to find file names like this one
/etc/pam.conf
, but instead the command above would give me something like this too /etc.dbus-1/system.d/org.freedesktop.bolt.conf
– george
2 days ago
Well, for example I wanted to find file names like this one
/etc/pam.conf
, but instead the command above would give me something like this too /etc.dbus-1/system.d/org.freedesktop.bolt.conf
– george
2 days ago
What about a hidden
.ltrace.conf
file for instance?– Stéphane Chazelas
2 days ago
What about a hidden
.ltrace.conf
file for instance?– Stéphane Chazelas
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You could exclude the file names that contain more than one dot:
find /etc -type f ! -name '*.*.*' -name '*.conf'
If you still want to print hidden .conf
file names (if any, à la /etc/.pwd.lock
) then
find /etc -type f ! -name '?*.*.*' -name '*.conf'
Suppose I am having a file with namea.b.conf
. Wherea.b
is the name of the file and.conf
is extension.
– Debian_yadav
2 days ago
@Debian_yadav - according to you, according to the next guy the file name isa
andb
is another extension... you know, liketar
intar.gz
...
– don_crissti
2 days ago
One might prefer! -name '?*.*.*'
to allow files named like.socks.conf
for instance, where.socks
can't possibly be considered as an extension (it's rare to find such files in/etc
except maybe in/etc/skel
though).
– Stéphane Chazelas
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You could exclude the file names that contain more than one dot:
find /etc -type f ! -name '*.*.*' -name '*.conf'
If you still want to print hidden .conf
file names (if any, à la /etc/.pwd.lock
) then
find /etc -type f ! -name '?*.*.*' -name '*.conf'
Suppose I am having a file with namea.b.conf
. Wherea.b
is the name of the file and.conf
is extension.
– Debian_yadav
2 days ago
@Debian_yadav - according to you, according to the next guy the file name isa
andb
is another extension... you know, liketar
intar.gz
...
– don_crissti
2 days ago
One might prefer! -name '?*.*.*'
to allow files named like.socks.conf
for instance, where.socks
can't possibly be considered as an extension (it's rare to find such files in/etc
except maybe in/etc/skel
though).
– Stéphane Chazelas
2 days ago
add a comment |
up vote
0
down vote
You could exclude the file names that contain more than one dot:
find /etc -type f ! -name '*.*.*' -name '*.conf'
If you still want to print hidden .conf
file names (if any, à la /etc/.pwd.lock
) then
find /etc -type f ! -name '?*.*.*' -name '*.conf'
Suppose I am having a file with namea.b.conf
. Wherea.b
is the name of the file and.conf
is extension.
– Debian_yadav
2 days ago
@Debian_yadav - according to you, according to the next guy the file name isa
andb
is another extension... you know, liketar
intar.gz
...
– don_crissti
2 days ago
One might prefer! -name '?*.*.*'
to allow files named like.socks.conf
for instance, where.socks
can't possibly be considered as an extension (it's rare to find such files in/etc
except maybe in/etc/skel
though).
– Stéphane Chazelas
2 days ago
add a comment |
up vote
0
down vote
up vote
0
down vote
You could exclude the file names that contain more than one dot:
find /etc -type f ! -name '*.*.*' -name '*.conf'
If you still want to print hidden .conf
file names (if any, à la /etc/.pwd.lock
) then
find /etc -type f ! -name '?*.*.*' -name '*.conf'
You could exclude the file names that contain more than one dot:
find /etc -type f ! -name '*.*.*' -name '*.conf'
If you still want to print hidden .conf
file names (if any, à la /etc/.pwd.lock
) then
find /etc -type f ! -name '?*.*.*' -name '*.conf'
edited 2 days ago
community wiki
2 revs
don_crissti
Suppose I am having a file with namea.b.conf
. Wherea.b
is the name of the file and.conf
is extension.
– Debian_yadav
2 days ago
@Debian_yadav - according to you, according to the next guy the file name isa
andb
is another extension... you know, liketar
intar.gz
...
– don_crissti
2 days ago
One might prefer! -name '?*.*.*'
to allow files named like.socks.conf
for instance, where.socks
can't possibly be considered as an extension (it's rare to find such files in/etc
except maybe in/etc/skel
though).
– Stéphane Chazelas
2 days ago
add a comment |
Suppose I am having a file with namea.b.conf
. Wherea.b
is the name of the file and.conf
is extension.
– Debian_yadav
2 days ago
@Debian_yadav - according to you, according to the next guy the file name isa
andb
is another extension... you know, liketar
intar.gz
...
– don_crissti
2 days ago
One might prefer! -name '?*.*.*'
to allow files named like.socks.conf
for instance, where.socks
can't possibly be considered as an extension (it's rare to find such files in/etc
except maybe in/etc/skel
though).
– Stéphane Chazelas
2 days ago
Suppose I am having a file with name
a.b.conf
. Where a.b
is the name of the file and .conf
is extension.– Debian_yadav
2 days ago
Suppose I am having a file with name
a.b.conf
. Where a.b
is the name of the file and .conf
is extension.– Debian_yadav
2 days ago
@Debian_yadav - according to you, according to the next guy the file name is
a
and b
is another extension... you know, like tar
in tar.gz
...– don_crissti
2 days ago
@Debian_yadav - according to you, according to the next guy the file name is
a
and b
is another extension... you know, like tar
in tar.gz
...– don_crissti
2 days ago
One might prefer
! -name '?*.*.*'
to allow files named like .socks.conf
for instance, where .socks
can't possibly be considered as an extension (it's rare to find such files in /etc
except maybe in /etc/skel
though).– Stéphane Chazelas
2 days ago
One might prefer
! -name '?*.*.*'
to allow files named like .socks.conf
for instance, where .socks
can't possibly be considered as an extension (it's rare to find such files in /etc
except maybe in /etc/skel
though).– Stéphane Chazelas
2 days ago
add a comment |
george is a new contributor. Be nice, and check out our Code of Conduct.
george is a new contributor. Be nice, and check out our Code of Conduct.
george is a new contributor. Be nice, and check out our Code of Conduct.
george is a new contributor. Be nice, and check out our Code of Conduct.
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%2f482023%2feliminating-multiple-extension-file-names-from-find-output%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
What do you mean by
two or three extensions
, can you clarify on that– sla3k
2 days ago
How do you define an extension? What if the file name is
a.b.conf
. Wherea.b
is file name and.conf
is an extension?– Debian_yadav
2 days ago
Well, for example I wanted to find file names like this one
/etc/pam.conf
, but instead the command above would give me something like this too/etc.dbus-1/system.d/org.freedesktop.bolt.conf
– george
2 days ago
What about a hidden
.ltrace.conf
file for instance?– Stéphane Chazelas
2 days ago