combining options in find command from a letter to another
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
Find all the files in /etc
that have .config
and starts with letter a
to the files that starts with letter k
, that's means all the files from a to k
in /etc .config.
linux debian find command
add a comment |Â
up vote
-2
down vote
favorite
Find all the files in /etc
that have .config
and starts with letter a
to the files that starts with letter k
, that's means all the files from a to k
in /etc .config.
linux debian find command
Hi and welcome. What have you tried? Where are you having trouble?
â Andy Dalton
Sep 5 at 17:23
maybeecho /etc/[a-k]*.conflig*
?
â Doug O'Neal
Sep 5 at 17:24
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
Find all the files in /etc
that have .config
and starts with letter a
to the files that starts with letter k
, that's means all the files from a to k
in /etc .config.
linux debian find command
Find all the files in /etc
that have .config
and starts with letter a
to the files that starts with letter k
, that's means all the files from a to k
in /etc .config.
linux debian find command
linux debian find command
edited Sep 6 at 8:10
GAD3R
23k164896
23k164896
asked Sep 5 at 17:18
Alnasir Khalid
14
14
Hi and welcome. What have you tried? Where are you having trouble?
â Andy Dalton
Sep 5 at 17:23
maybeecho /etc/[a-k]*.conflig*
?
â Doug O'Neal
Sep 5 at 17:24
add a comment |Â
Hi and welcome. What have you tried? Where are you having trouble?
â Andy Dalton
Sep 5 at 17:23
maybeecho /etc/[a-k]*.conflig*
?
â Doug O'Neal
Sep 5 at 17:24
Hi and welcome. What have you tried? Where are you having trouble?
â Andy Dalton
Sep 5 at 17:23
Hi and welcome. What have you tried? Where are you having trouble?
â Andy Dalton
Sep 5 at 17:23
maybe
echo /etc/[a-k]*.conflig*
?â Doug O'Neal
Sep 5 at 17:24
maybe
echo /etc/[a-k]*.conflig*
?â Doug O'Neal
Sep 5 at 17:24
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Those filenames would match the filename globbing pattern [a-k]*.config
("starts with any of the letters a
through to k
, and ends with the filename suffix .config
").
If you're only interested in files located in /etc
, then the following command would list these files:
printf '%sn' /etc/[a-k]*.config
That command would also list directories and symbolic links (etc.) that matched the pattern. To restrict the list to only regular files (and symbolic links to regular files), then use a loop:
for pathname in /etc/[a-k]*.config; do
[ ! -f "$pathname" ] && continue
printf '%sn' "$pathname"
done
If you are interested in looking into subdirectories of /etc
and to restrict the search to only include regular files, then use find
:
find /etc -type f -name '[a-k]*.config'
This would look in and below /etc
for regular files (-type f
) that has filenames matching the given pattern.
The result of the commands above would be a newline-delimited list of pathnames of files. This list should probably not be used as an intermediate list of pathnames if you're planning on doing further processing of the files. Instead, use the loop above to process the files individually, or use find
with its -exec
option to process them. This is because the delimiter used in the output, newline, is also a valid character in Unix filenames (granted, you very rarely see it in use, but none the less).
Thank you so much !, that was so helpful !
â Alnasir Khalid
Sep 5 at 17:39
You may want to set the locale to C for that[a-k]
to match on[abcdefghijk]
only. Especially true withbash
where[a-k]
also matches on[ABCDEFGHIJ]
or[BCDEFGHIJK]
in most locales at least on GNU systems. Or use[abcdefghijk]
â Stéphane Chazelas
Sep 6 at 8:20
[ -f filename ]
also matches on symlinks to regular files. Just usezsh
and/etc/[a-k]*.config(.)
that has none of those issues (the[a-k]
range is based on codepoint tere,(.)
is for regular file only, use(-.)
for regular file after symlink resolution.
â Stéphane Chazelas
Sep 6 at 8:22
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Those filenames would match the filename globbing pattern [a-k]*.config
("starts with any of the letters a
through to k
, and ends with the filename suffix .config
").
If you're only interested in files located in /etc
, then the following command would list these files:
printf '%sn' /etc/[a-k]*.config
That command would also list directories and symbolic links (etc.) that matched the pattern. To restrict the list to only regular files (and symbolic links to regular files), then use a loop:
for pathname in /etc/[a-k]*.config; do
[ ! -f "$pathname" ] && continue
printf '%sn' "$pathname"
done
If you are interested in looking into subdirectories of /etc
and to restrict the search to only include regular files, then use find
:
find /etc -type f -name '[a-k]*.config'
This would look in and below /etc
for regular files (-type f
) that has filenames matching the given pattern.
The result of the commands above would be a newline-delimited list of pathnames of files. This list should probably not be used as an intermediate list of pathnames if you're planning on doing further processing of the files. Instead, use the loop above to process the files individually, or use find
with its -exec
option to process them. This is because the delimiter used in the output, newline, is also a valid character in Unix filenames (granted, you very rarely see it in use, but none the less).
Thank you so much !, that was so helpful !
â Alnasir Khalid
Sep 5 at 17:39
You may want to set the locale to C for that[a-k]
to match on[abcdefghijk]
only. Especially true withbash
where[a-k]
also matches on[ABCDEFGHIJ]
or[BCDEFGHIJK]
in most locales at least on GNU systems. Or use[abcdefghijk]
â Stéphane Chazelas
Sep 6 at 8:20
[ -f filename ]
also matches on symlinks to regular files. Just usezsh
and/etc/[a-k]*.config(.)
that has none of those issues (the[a-k]
range is based on codepoint tere,(.)
is for regular file only, use(-.)
for regular file after symlink resolution.
â Stéphane Chazelas
Sep 6 at 8:22
add a comment |Â
up vote
1
down vote
accepted
Those filenames would match the filename globbing pattern [a-k]*.config
("starts with any of the letters a
through to k
, and ends with the filename suffix .config
").
If you're only interested in files located in /etc
, then the following command would list these files:
printf '%sn' /etc/[a-k]*.config
That command would also list directories and symbolic links (etc.) that matched the pattern. To restrict the list to only regular files (and symbolic links to regular files), then use a loop:
for pathname in /etc/[a-k]*.config; do
[ ! -f "$pathname" ] && continue
printf '%sn' "$pathname"
done
If you are interested in looking into subdirectories of /etc
and to restrict the search to only include regular files, then use find
:
find /etc -type f -name '[a-k]*.config'
This would look in and below /etc
for regular files (-type f
) that has filenames matching the given pattern.
The result of the commands above would be a newline-delimited list of pathnames of files. This list should probably not be used as an intermediate list of pathnames if you're planning on doing further processing of the files. Instead, use the loop above to process the files individually, or use find
with its -exec
option to process them. This is because the delimiter used in the output, newline, is also a valid character in Unix filenames (granted, you very rarely see it in use, but none the less).
Thank you so much !, that was so helpful !
â Alnasir Khalid
Sep 5 at 17:39
You may want to set the locale to C for that[a-k]
to match on[abcdefghijk]
only. Especially true withbash
where[a-k]
also matches on[ABCDEFGHIJ]
or[BCDEFGHIJK]
in most locales at least on GNU systems. Or use[abcdefghijk]
â Stéphane Chazelas
Sep 6 at 8:20
[ -f filename ]
also matches on symlinks to regular files. Just usezsh
and/etc/[a-k]*.config(.)
that has none of those issues (the[a-k]
range is based on codepoint tere,(.)
is for regular file only, use(-.)
for regular file after symlink resolution.
â Stéphane Chazelas
Sep 6 at 8:22
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Those filenames would match the filename globbing pattern [a-k]*.config
("starts with any of the letters a
through to k
, and ends with the filename suffix .config
").
If you're only interested in files located in /etc
, then the following command would list these files:
printf '%sn' /etc/[a-k]*.config
That command would also list directories and symbolic links (etc.) that matched the pattern. To restrict the list to only regular files (and symbolic links to regular files), then use a loop:
for pathname in /etc/[a-k]*.config; do
[ ! -f "$pathname" ] && continue
printf '%sn' "$pathname"
done
If you are interested in looking into subdirectories of /etc
and to restrict the search to only include regular files, then use find
:
find /etc -type f -name '[a-k]*.config'
This would look in and below /etc
for regular files (-type f
) that has filenames matching the given pattern.
The result of the commands above would be a newline-delimited list of pathnames of files. This list should probably not be used as an intermediate list of pathnames if you're planning on doing further processing of the files. Instead, use the loop above to process the files individually, or use find
with its -exec
option to process them. This is because the delimiter used in the output, newline, is also a valid character in Unix filenames (granted, you very rarely see it in use, but none the less).
Those filenames would match the filename globbing pattern [a-k]*.config
("starts with any of the letters a
through to k
, and ends with the filename suffix .config
").
If you're only interested in files located in /etc
, then the following command would list these files:
printf '%sn' /etc/[a-k]*.config
That command would also list directories and symbolic links (etc.) that matched the pattern. To restrict the list to only regular files (and symbolic links to regular files), then use a loop:
for pathname in /etc/[a-k]*.config; do
[ ! -f "$pathname" ] && continue
printf '%sn' "$pathname"
done
If you are interested in looking into subdirectories of /etc
and to restrict the search to only include regular files, then use find
:
find /etc -type f -name '[a-k]*.config'
This would look in and below /etc
for regular files (-type f
) that has filenames matching the given pattern.
The result of the commands above would be a newline-delimited list of pathnames of files. This list should probably not be used as an intermediate list of pathnames if you're planning on doing further processing of the files. Instead, use the loop above to process the files individually, or use find
with its -exec
option to process them. This is because the delimiter used in the output, newline, is also a valid character in Unix filenames (granted, you very rarely see it in use, but none the less).
edited Sep 6 at 8:33
answered Sep 5 at 17:32
Kusalananda
107k14209331
107k14209331
Thank you so much !, that was so helpful !
â Alnasir Khalid
Sep 5 at 17:39
You may want to set the locale to C for that[a-k]
to match on[abcdefghijk]
only. Especially true withbash
where[a-k]
also matches on[ABCDEFGHIJ]
or[BCDEFGHIJK]
in most locales at least on GNU systems. Or use[abcdefghijk]
â Stéphane Chazelas
Sep 6 at 8:20
[ -f filename ]
also matches on symlinks to regular files. Just usezsh
and/etc/[a-k]*.config(.)
that has none of those issues (the[a-k]
range is based on codepoint tere,(.)
is for regular file only, use(-.)
for regular file after symlink resolution.
â Stéphane Chazelas
Sep 6 at 8:22
add a comment |Â
Thank you so much !, that was so helpful !
â Alnasir Khalid
Sep 5 at 17:39
You may want to set the locale to C for that[a-k]
to match on[abcdefghijk]
only. Especially true withbash
where[a-k]
also matches on[ABCDEFGHIJ]
or[BCDEFGHIJK]
in most locales at least on GNU systems. Or use[abcdefghijk]
â Stéphane Chazelas
Sep 6 at 8:20
[ -f filename ]
also matches on symlinks to regular files. Just usezsh
and/etc/[a-k]*.config(.)
that has none of those issues (the[a-k]
range is based on codepoint tere,(.)
is for regular file only, use(-.)
for regular file after symlink resolution.
â Stéphane Chazelas
Sep 6 at 8:22
Thank you so much !, that was so helpful !
â Alnasir Khalid
Sep 5 at 17:39
Thank you so much !, that was so helpful !
â Alnasir Khalid
Sep 5 at 17:39
You may want to set the locale to C for that
[a-k]
to match on [abcdefghijk]
only. Especially true with bash
where [a-k]
also matches on [ABCDEFGHIJ]
or [BCDEFGHIJK]
in most locales at least on GNU systems. Or use [abcdefghijk]
â Stéphane Chazelas
Sep 6 at 8:20
You may want to set the locale to C for that
[a-k]
to match on [abcdefghijk]
only. Especially true with bash
where [a-k]
also matches on [ABCDEFGHIJ]
or [BCDEFGHIJK]
in most locales at least on GNU systems. Or use [abcdefghijk]
â Stéphane Chazelas
Sep 6 at 8:20
[ -f filename ]
also matches on symlinks to regular files. Just use zsh
and /etc/[a-k]*.config(.)
that has none of those issues (the [a-k]
range is based on codepoint tere, (.)
is for regular file only, use (-.)
for regular file after symlink resolution.â Stéphane Chazelas
Sep 6 at 8:22
[ -f filename ]
also matches on symlinks to regular files. Just use zsh
and /etc/[a-k]*.config(.)
that has none of those issues (the [a-k]
range is based on codepoint tere, (.)
is for regular file only, use (-.)
for regular file after symlink resolution.â Stéphane Chazelas
Sep 6 at 8:22
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467083%2fcombining-options-in-find-command-from-a-letter-to-another%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Hi and welcome. What have you tried? Where are you having trouble?
â Andy Dalton
Sep 5 at 17:23
maybe
echo /etc/[a-k]*.conflig*
?â Doug O'Neal
Sep 5 at 17:24