combining options in find command from a letter to another

The name of the pictureThe name of the pictureThe name of the pictureClash 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.










share|improve this question























  • 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














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.










share|improve this question























  • 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












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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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










  • maybe echo /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










  • maybe echo /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










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).






share|improve this answer






















  • 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











  • [ -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










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: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
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%2f467083%2fcombining-options-in-find-command-from-a-letter-to-another%23new-answer', 'question_page');

);

Post as a guest






























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).






share|improve this answer






















  • 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











  • [ -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














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).






share|improve this answer






















  • 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











  • [ -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












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).






share|improve this answer














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).







share|improve this answer














share|improve this answer



share|improve this answer








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 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
















  • 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











  • [ -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















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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?