198k views
1 vote
Find command

Evaluate your find command comprehension by completing the following tasks:

In your ~/workspacedirectory:
Find - with a max directory depth of 1 - only the files that begin with the letter h and redirect the output to a ~/workspace/project-log/files-with-h.txt file

Enter the ~/workspace/project-logdirectory and find all the files ending with the .txt pattern in the current directory

Once you have completed these tasks press the Check It button to have your solution assessed.

User Nbermudezs
by
4.1k points

1 Answer

5 votes

Final answer:

The question involves using the find command to locate files in a Linux environment that begin with the letter 'h' and to find .txt files in a particular directory, with results of the first task saved in a text file.

Step-by-step explanation:

The student's question pertains to the use of the find command in a Unix-like operating system to locate files within a directory structure. To address the tasks:

Finding Files Beginning with 'h':

Use the command find ~/workspace -maxdepth 1 -type f -name 'h*' > ~/workspace/project-log/files-with-h.txt. This command looks for files (-type f) starting with the letter 'h' (-name 'h*') in the ~/workspace directory with a maximum directory depth of 1 (-maxdepth 1), and redirects the output to the specified files-with-h.txt file.

Finding .txt Files in Current Directory:

To find all .txt files in the current directory, use the command find . -maxdepth 1 -type f -name '*.txt' while being in the directory ~/workspace/project-log. No redirection of output is specified for this task.

User IMemon
by
4.7k points