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
Cloud computing is often divided into three levels of services - infrastructure-as-a-service (IAAS), platform-as-a-service (PAAS
Alekssandra [29.7K]

Answer:

Infrastructure-as-a-Service

Explanation:

IaaS provides networking components such as backup, security, scaling, data partitioning and other vital computing resources needed. All these services are provided online using high-levels APIs (Application Programming Interface).

IaaS providers make resources available to customers from the equipment installed in data centers.

Therefore, the service that deals with networks, servers, and storage is Infrastructure-as-a-Service (IaaS

5 0
3 years ago
What do we call the distribution and access of illegal copies of digital books??
Maru [420]
That concept is piracy


3 0
3 years ago
Read 2 more answers
When developing an estimate, which of the following items is typically marked up with the highest percentage rate?
dmitriy555 [2]

Answer: D. Labor

Explanation:

8 0
1 year ago
2. Feet to Inches One foot equals 12 inches. Design a function named feetToInches that accepts a number of feet as an argument,
MariettaO [177]

Answer:

See the below the answer written in Matlab

Explanation:

function inches=feetToInches(feet)

prompt='enter the value of feet in digits';

feet=input(prompt)% ask for the value in feet that needs to be converted to inches

inches =feet*12; % converts feet to inches

x=['the value in inches is:  ',num2str(inches)];

disp(x) %display the result of the convertion

end

8 0
3 years ago
Discuss operations of vectors in computer graphics?
Allushta [10]

Answer:

  In the computer graphics, the vectors are basically used to compose various type of components. In the computer graphics it is basically known as vector graphics and it is composed of various types of components.

The operation of the vector in the computer vector is that it is basically used to create the digital images by the use of mathematical statement and command.

It is used to place the lines and the shape in the two- dimension and three- dimension spaces. IN the computer graphics, vectors are also used to represent the particular direction of the various objects.

6 0
2 years ago
Other questions:
  • How is sharepoint used in organization today?
    12·1 answer
  • Operational feasibility, which refers to user acceptance and support, as well as management acceptance and support, is also know
    9·1 answer
  • Suppose you have one particular application that is trying to send data on the Internet but none of the data is making it to the
    15·2 answers
  • How do u use this app?
    15·2 answers
  • What electronic device can represent a KiloByte?
    14·1 answer
  • Which of the following are the dimensions of feasibility? Group of answer choices cost, schedule, technical, and organizational
    14·1 answer
  • Apex
    5·2 answers
  • 2. Used to drive in or remove screws that fasten electrical wires or other electrical accessories. A. Pliers C. Screwdrivers B.
    15·1 answer
  • window operating system popularly known as. 1) character user interface. 2) computer user interface. 3) graphic user interface.
    15·1 answer
  • What is the engine for<br> ?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!