How can I find a file whose name fits a particular pattern using `find`?

Clash Royale CLAN TAG#URR8PPP up vote
-1
down vote
favorite
I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:
- file should start with letter
g - filename should have only 3 characters
- file extension must be
.d
The search should be performed with the command find.
16.04 command-line find
add a comment |Â
up vote
-1
down vote
favorite
I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:
- file should start with letter
g - filename should have only 3 characters
- file extension must be
.d
The search should be performed with the command find.
16.04 command-line find
Did you read thefindmanpage? What is unclear there?
â PerlDuck
Mar 18 at 9:11
How can I get help on terminal commands?
â dessert
Mar 18 at 9:17
Unclear how to find with only 3characters, starts with letter "g".
â Maxim Savchuk
Mar 18 at 9:20
2
File or filename should start with g? If filename, does the character limit include the.dextension?
â muru
Mar 18 at 10:30
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:
- file should start with letter
g - filename should have only 3 characters
- file extension must be
.d
The search should be performed with the command find.
16.04 command-line find
I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:
- file should start with letter
g - filename should have only 3 characters
- file extension must be
.d
The search should be performed with the command find.
16.04 command-line find
16.04 command-line find
edited Mar 20 at 12:31
Zanna
48.1k13120228
48.1k13120228
asked Mar 18 at 9:09
Maxim Savchuk
11
11
Did you read thefindmanpage? What is unclear there?
â PerlDuck
Mar 18 at 9:11
How can I get help on terminal commands?
â dessert
Mar 18 at 9:17
Unclear how to find with only 3characters, starts with letter "g".
â Maxim Savchuk
Mar 18 at 9:20
2
File or filename should start with g? If filename, does the character limit include the.dextension?
â muru
Mar 18 at 10:30
add a comment |Â
Did you read thefindmanpage? What is unclear there?
â PerlDuck
Mar 18 at 9:11
How can I get help on terminal commands?
â dessert
Mar 18 at 9:17
Unclear how to find with only 3characters, starts with letter "g".
â Maxim Savchuk
Mar 18 at 9:20
2
File or filename should start with g? If filename, does the character limit include the.dextension?
â muru
Mar 18 at 10:30
Did you read the
find manpage? What is unclear there?â PerlDuck
Mar 18 at 9:11
Did you read the
find manpage? What is unclear there?â PerlDuck
Mar 18 at 9:11
How can I get help on terminal commands?
â dessert
Mar 18 at 9:17
How can I get help on terminal commands?
â dessert
Mar 18 at 9:17
Unclear how to find with only 3characters, starts with letter "g".
â Maxim Savchuk
Mar 18 at 9:20
Unclear how to find with only 3characters, starts with letter "g".
â Maxim Savchuk
Mar 18 at 9:20
2
2
File or filename should start with g? If filename, does the character limit include the
.d extension?â muru
Mar 18 at 10:30
File or filename should start with g? If filename, does the character limit include the
.d extension?â muru
Mar 18 at 10:30
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
Since you are allowed to use the find command, this is quite simple:
find / -type f -name "g??.d"
This will find all files (-type f) with a name that starts
with g, followed by two arbitrary characters ??, followed
by .d (-name "g??.d") in the root directory / and below.
When run as non-root user you will get many permission denied
errors because not all directories below / are accessible
by non-root. Also, it may take a while.
Change / to the path where you want to start the search from,
e.g. /home/your_user or simply . for the current directory.
Add -ls to get not only the file's names but also their attributes
(size, age, permissions):
find . -type f -name "g??.d" -ls
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Since you are allowed to use the find command, this is quite simple:
find / -type f -name "g??.d"
This will find all files (-type f) with a name that starts
with g, followed by two arbitrary characters ??, followed
by .d (-name "g??.d") in the root directory / and below.
When run as non-root user you will get many permission denied
errors because not all directories below / are accessible
by non-root. Also, it may take a while.
Change / to the path where you want to start the search from,
e.g. /home/your_user or simply . for the current directory.
Add -ls to get not only the file's names but also their attributes
(size, age, permissions):
find . -type f -name "g??.d" -ls
add a comment |Â
up vote
4
down vote
accepted
Since you are allowed to use the find command, this is quite simple:
find / -type f -name "g??.d"
This will find all files (-type f) with a name that starts
with g, followed by two arbitrary characters ??, followed
by .d (-name "g??.d") in the root directory / and below.
When run as non-root user you will get many permission denied
errors because not all directories below / are accessible
by non-root. Also, it may take a while.
Change / to the path where you want to start the search from,
e.g. /home/your_user or simply . for the current directory.
Add -ls to get not only the file's names but also their attributes
(size, age, permissions):
find . -type f -name "g??.d" -ls
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Since you are allowed to use the find command, this is quite simple:
find / -type f -name "g??.d"
This will find all files (-type f) with a name that starts
with g, followed by two arbitrary characters ??, followed
by .d (-name "g??.d") in the root directory / and below.
When run as non-root user you will get many permission denied
errors because not all directories below / are accessible
by non-root. Also, it may take a while.
Change / to the path where you want to start the search from,
e.g. /home/your_user or simply . for the current directory.
Add -ls to get not only the file's names but also their attributes
(size, age, permissions):
find . -type f -name "g??.d" -ls
Since you are allowed to use the find command, this is quite simple:
find / -type f -name "g??.d"
This will find all files (-type f) with a name that starts
with g, followed by two arbitrary characters ??, followed
by .d (-name "g??.d") in the root directory / and below.
When run as non-root user you will get many permission denied
errors because not all directories below / are accessible
by non-root. Also, it may take a while.
Change / to the path where you want to start the search from,
e.g. /home/your_user or simply . for the current directory.
Add -ls to get not only the file's names but also their attributes
(size, age, permissions):
find . -type f -name "g??.d" -ls
answered Mar 18 at 10:20
PerlDuck
3,92811030
3,92811030
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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%2faskubuntu.com%2fquestions%2f1016942%2fhow-can-i-find-a-file-whose-name-fits-a-particular-pattern-using-find%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
Did you read the
findmanpage? What is unclear there?â PerlDuck
Mar 18 at 9:11
How can I get help on terminal commands?
â dessert
Mar 18 at 9:17
Unclear how to find with only 3characters, starts with letter "g".
â Maxim Savchuk
Mar 18 at 9:20
2
File or filename should start with g? If filename, does the character limit include the
.dextension?â muru
Mar 18 at 10:30