-1

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.

Zanna
  • 70,465

1 Answers1

4

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
PerlDuck
  • 13,335