Regex that matches only dirnames with integers and dots

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Trying to write -regex for a find statement that shows only directories with dots and numbers, for example 1.2.3.4 oraz 1.2.3 or 1.3.4.5.6 was trying something like "-regex '.[0-9.]+'", but it also shows dirs with letters. And I only want directories with numbers and dots.
linux find regular-expression
add a comment |Â
up vote
0
down vote
favorite
Trying to write -regex for a find statement that shows only directories with dots and numbers, for example 1.2.3.4 oraz 1.2.3 or 1.3.4.5.6 was trying something like "-regex '.[0-9.]+'", but it also shows dirs with letters. And I only want directories with numbers and dots.
linux find regular-expression
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Trying to write -regex for a find statement that shows only directories with dots and numbers, for example 1.2.3.4 oraz 1.2.3 or 1.3.4.5.6 was trying something like "-regex '.[0-9.]+'", but it also shows dirs with letters. And I only want directories with numbers and dots.
linux find regular-expression
Trying to write -regex for a find statement that shows only directories with dots and numbers, for example 1.2.3.4 oraz 1.2.3 or 1.3.4.5.6 was trying something like "-regex '.[0-9.]+'", but it also shows dirs with letters. And I only want directories with numbers and dots.
linux find regular-expression
edited Nov 12 '17 at 15:25
asked Nov 12 '17 at 15:02
harcotlupus
686
686
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
-regex matches the whole path:
find /path -type d -regex ".*/[0-9.]+"
But doesn't it allows letters on other positions?
â harcotlupus
Nov 12 '17 at 15:11
You mean inside the path? Yes, this will find any directory which has only[0-9.]in its name, regardless of the path. If you want to match[0-9.]in the whole path use-regex "[0-9./]+"instead.
â dessert
Nov 12 '17 at 15:14
It's like, I have directory which contains other directories for example something.txt something2.txt 1.2.3.4 5.6.8 4.3.2 and I want to show only those which contains only numbers and dots But both answers show's me also directories with characters...
â harcotlupus
Nov 12 '17 at 15:30
Sorry, I've eddited last comment :)
â harcotlupus
Nov 12 '17 at 15:32
Your code is working, don't know why in first place it didn't worked
â harcotlupus
Nov 12 '17 at 16:15
add a comment |Â
up vote
0
down vote
Standardly:
LC_ALL=C find /path ! -name '*[!0-9.]*' -type d
That is, list files of type directory whose name doesn't not contain a character other than decimal digit or ..
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
-regex matches the whole path:
find /path -type d -regex ".*/[0-9.]+"
But doesn't it allows letters on other positions?
â harcotlupus
Nov 12 '17 at 15:11
You mean inside the path? Yes, this will find any directory which has only[0-9.]in its name, regardless of the path. If you want to match[0-9.]in the whole path use-regex "[0-9./]+"instead.
â dessert
Nov 12 '17 at 15:14
It's like, I have directory which contains other directories for example something.txt something2.txt 1.2.3.4 5.6.8 4.3.2 and I want to show only those which contains only numbers and dots But both answers show's me also directories with characters...
â harcotlupus
Nov 12 '17 at 15:30
Sorry, I've eddited last comment :)
â harcotlupus
Nov 12 '17 at 15:32
Your code is working, don't know why in first place it didn't worked
â harcotlupus
Nov 12 '17 at 16:15
add a comment |Â
up vote
1
down vote
accepted
-regex matches the whole path:
find /path -type d -regex ".*/[0-9.]+"
But doesn't it allows letters on other positions?
â harcotlupus
Nov 12 '17 at 15:11
You mean inside the path? Yes, this will find any directory which has only[0-9.]in its name, regardless of the path. If you want to match[0-9.]in the whole path use-regex "[0-9./]+"instead.
â dessert
Nov 12 '17 at 15:14
It's like, I have directory which contains other directories for example something.txt something2.txt 1.2.3.4 5.6.8 4.3.2 and I want to show only those which contains only numbers and dots But both answers show's me also directories with characters...
â harcotlupus
Nov 12 '17 at 15:30
Sorry, I've eddited last comment :)
â harcotlupus
Nov 12 '17 at 15:32
Your code is working, don't know why in first place it didn't worked
â harcotlupus
Nov 12 '17 at 16:15
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
-regex matches the whole path:
find /path -type d -regex ".*/[0-9.]+"
-regex matches the whole path:
find /path -type d -regex ".*/[0-9.]+"
answered Nov 12 '17 at 15:09
dessert
1,013321
1,013321
But doesn't it allows letters on other positions?
â harcotlupus
Nov 12 '17 at 15:11
You mean inside the path? Yes, this will find any directory which has only[0-9.]in its name, regardless of the path. If you want to match[0-9.]in the whole path use-regex "[0-9./]+"instead.
â dessert
Nov 12 '17 at 15:14
It's like, I have directory which contains other directories for example something.txt something2.txt 1.2.3.4 5.6.8 4.3.2 and I want to show only those which contains only numbers and dots But both answers show's me also directories with characters...
â harcotlupus
Nov 12 '17 at 15:30
Sorry, I've eddited last comment :)
â harcotlupus
Nov 12 '17 at 15:32
Your code is working, don't know why in first place it didn't worked
â harcotlupus
Nov 12 '17 at 16:15
add a comment |Â
But doesn't it allows letters on other positions?
â harcotlupus
Nov 12 '17 at 15:11
You mean inside the path? Yes, this will find any directory which has only[0-9.]in its name, regardless of the path. If you want to match[0-9.]in the whole path use-regex "[0-9./]+"instead.
â dessert
Nov 12 '17 at 15:14
It's like, I have directory which contains other directories for example something.txt something2.txt 1.2.3.4 5.6.8 4.3.2 and I want to show only those which contains only numbers and dots But both answers show's me also directories with characters...
â harcotlupus
Nov 12 '17 at 15:30
Sorry, I've eddited last comment :)
â harcotlupus
Nov 12 '17 at 15:32
Your code is working, don't know why in first place it didn't worked
â harcotlupus
Nov 12 '17 at 16:15
But doesn't it allows letters on other positions?
â harcotlupus
Nov 12 '17 at 15:11
But doesn't it allows letters on other positions?
â harcotlupus
Nov 12 '17 at 15:11
You mean inside the path? Yes, this will find any directory which has only
[0-9.] in its name, regardless of the path. If you want to match [0-9.] in the whole path use -regex "[0-9./]+" instead.â dessert
Nov 12 '17 at 15:14
You mean inside the path? Yes, this will find any directory which has only
[0-9.] in its name, regardless of the path. If you want to match [0-9.] in the whole path use -regex "[0-9./]+" instead.â dessert
Nov 12 '17 at 15:14
It's like, I have directory which contains other directories for example something.txt something2.txt 1.2.3.4 5.6.8 4.3.2 and I want to show only those which contains only numbers and dots But both answers show's me also directories with characters...
â harcotlupus
Nov 12 '17 at 15:30
It's like, I have directory which contains other directories for example something.txt something2.txt 1.2.3.4 5.6.8 4.3.2 and I want to show only those which contains only numbers and dots But both answers show's me also directories with characters...
â harcotlupus
Nov 12 '17 at 15:30
Sorry, I've eddited last comment :)
â harcotlupus
Nov 12 '17 at 15:32
Sorry, I've eddited last comment :)
â harcotlupus
Nov 12 '17 at 15:32
Your code is working, don't know why in first place it didn't worked
â harcotlupus
Nov 12 '17 at 16:15
Your code is working, don't know why in first place it didn't worked
â harcotlupus
Nov 12 '17 at 16:15
add a comment |Â
up vote
0
down vote
Standardly:
LC_ALL=C find /path ! -name '*[!0-9.]*' -type d
That is, list files of type directory whose name doesn't not contain a character other than decimal digit or ..
add a comment |Â
up vote
0
down vote
Standardly:
LC_ALL=C find /path ! -name '*[!0-9.]*' -type d
That is, list files of type directory whose name doesn't not contain a character other than decimal digit or ..
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Standardly:
LC_ALL=C find /path ! -name '*[!0-9.]*' -type d
That is, list files of type directory whose name doesn't not contain a character other than decimal digit or ..
Standardly:
LC_ALL=C find /path ! -name '*[!0-9.]*' -type d
That is, list files of type directory whose name doesn't not contain a character other than decimal digit or ..
answered Apr 23 at 15:10
Stéphane Chazelas
283k53521854
283k53521854
add a comment |Â
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%2f404051%2fregex-that-matches-only-dirnames-with-integers-and-dots%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