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
If your computers normal zoom is 100, but it looks like its at 500, how do you stop that? my invisioned thing isn't on, neither
Alex Ar [27]

Answer:

You just need to click over the desktop, move to the View, and then change to medium, if its the icon size.

However, if you feel your resolution requires screwing up, then you are required to do the right-click, and again over the Desktop and then move to the settings (screen resolution),

And if you by chance clicked on the magnifier utility, you can CTRL + ALT +DEL and you will also be required to shut the interface.

Explanation:

You just need to click over the desktop, move to the View, and then change to medium, if its the icon size.

However, if you feel your resolution requires screwing up, then you are required to do the right-click, and again over the Desktop and then move to the settings (screen resolution),

And if you by chance clicked on the magnifier utility, you can CTRL + ALT +DEL and you will also be required to shut the interface.

7 0
4 years ago
Preesure is drived quantity? why​
Marrrta [24]

Answer:

Basically, anything quantity that is not defined as one of the 7 base quantities is a derived quantity by definition. Pressure is not one of the 7 base quantities. Hence it is a derived quantity.

6 0
4 years ago
Read 2 more answers
What are the basic components of a Production System?
Fudgin [204]

Answer:

a) Input: Energy entered

b) Conversion process: Applies action

c) Outputs: Information that is been taken out.

Explanation:

Hope it is right and helps.

3 0
3 years ago
Sub to splashy
tatyana61 [14]
Ok well make that 19 now
7 0
3 years ago
Read 2 more answers
Which protocol is used for secure websites? <br> FTP<br> HTTP<br> HTTPS<br> SFTP
givi [52]
HTTPS is the answer.
Hypertext transfer protocol secure
5 0
3 years ago
Other questions:
  • Can someone show me a image of this completed I will mark brainliest!!! It's typing.com
    11·1 answer
  • Which of the following is a domestic business activity?
    6·2 answers
  • The internet is a worldwide assembly of computer
    11·1 answer
  • Software companies will often release a(n) ___ version to a limited audience that will test it on their systems. Programmers can
    11·1 answer
  • Explain Spreadsheet and its Basics
    13·1 answer
  • Which statement describes Augmented Reality (AR) technology?
    12·1 answer
  • Conduct research to determine the best network design to ensure security of internal access while retaining public website avail
    9·1 answer
  • How do I mark brainlyist
    7·2 answers
  • Why might a programmer want to define his or her own functions? What are some potential disadvantages? How might new functions m
    10·1 answer
  • What causes the hidden node problem in a wireless local area network (wlan)?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!