1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alexira [117]
3 years ago
9

Write a Unix (Linux) find-like command (myFind) in Python3 where the function will return the full paths of all the files contai

ning the specified substring at the command line by recursively searching all the files and subdirectories starting from the specified directory. At the end of the command, it also returns the total file size of those files found in bytes . The total file size should be the summation of the file sizes of the regular files only.
Computers and Technology
1 answer:
Leno4ka [110]3 years ago
5 0

Answer:

import os, sys, stat

from stat import *

command = 'find ' + sys.argv[1] + ' -name *' + sys.argv[2] + '*'

print(command)

totalFiles = os.popen(command).read()

totalFiles = totalFiles.split()

totalSize = 0

for line in totalFiles:

  statinfo = os.stat(line)

 

  if stat.S_ISREG(statinfo.st_mode):

      print(line, statinfo.st_size, 'bytes')

      totalSize += statinfo.st_size

  else:

      print(line, '...')

print('Total file size:', totalSize, 'bytes')

Explanation:

  • According to command line arguments, build the find command.
  • Store the product by executing the command.
  • Loop through all files in the output list using the for loop.
  • Display the file name and size, If the file is regular otherwise just display the file name.
You might be interested in
ASAP! WILL MARK BRAINLIEST + 100 POINTS!!<br><br> Match each word to its description.
Naily [24]

When was the Ming dynasty established?

the 1100s CE

the 1200s CE

the 1300s CE

the 1400s CE

4 0
2 years ago
Read 2 more answers
In which two places are a keyboard usually held on a laptop?
Margarita [4]

Answer:

Bottom of the case

Through a connector

Explanation:

Regularly we must see the bottom of the case to remove some screws, and then move the keyboard, but first, you have to remove a connector.

The keyboards have evolved from windows and IMB built their own keyboards for desktop, and now we have digital keyboards, and replace a keyboard in a laptop can change for the model or the size.

6 0
3 years ago
Suppose an initially-empty queue Q has performed a total of 32 enqueue operations, 10 front operations, and 15 dequeue operation
Natasha_Volkova [10]

Answer:

22

Explanation:

1. We are going to have at hand 32 Enqueue Operation, with 10 from front and 15 dequeue and 5 empty queue operation

2. You dequeued total number of 15-5 =10 elements since 5 dequeue did not change the state of the queue, so invariably 10 dequeue is done.

3. Next is to enqueued a total of 32 elements.

Enqueue Operation do not change the state(and Size) of the queue, and can be ignored.

4. To arrive at the Total Size of queue, we will have 32-10 = 22 at the end

Answer : 22 because its a 5 dequeue Operations.

6 0
3 years ago
Why is successful pattern recognition important for computer programmers?
NISA [10]
Pattern recognition is a branch of machine learning that focuses on the recognition of patterns and regularities in data, although it is in some cases considered to be nearly synonymous with machine learning.
7 0
3 years ago
Ben wants to create a Book class that has an instance variable serialNumber. Where should he declare the instance variable
MrMuchimi

Answer:

within the Book class but needs to also be outside of any methods.

Explanation:

If Ben is creating an entire Book class then the instance variable needs to be within the Book class but needs to also be outside of any methods. If Ben places the variable inside a method it can only be used by that method and therefore becomes an instance variable of that method and not the class. By creating it inside the class and outside the methods it can be used every single time a Book object is created. Therefore, creating an instance variable of serialNumber every time.

4 0
3 years ago
Other questions:
  • Why is it unlikely that you will find the ip address 192.168.250.10 on the internet?
    15·1 answer
  • What is Hadoop?
    15·1 answer
  • ___________ is an approach to boundary spanning that results from using sophisticated software to search through large amounts o
    8·1 answer
  • I don’t understand the double8 coding problem. It is Java
    15·1 answer
  • [C++ for array week|
    8·1 answer
  • A part-time job performed while in high school must have the approval of your school counselor.
    7·2 answers
  • Vanessa is a set designer. She is working on a period film set in Egypt. She has selected several items for a scene in a palace.
    7·2 answers
  • HURRY please!!!!
    13·1 answer
  • Select each of the steps involved in creating a table in a presentation.
    12·1 answer
  • A data use agreement is required when a researcher uses a limited data set (lds). an lds must have:_________
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!