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
Obtain the 10’s complement of the following six-digit decimal numbers:<br><br> 123900<br><br> 980657
zysi [14]

Answer:

876100

019343

Explanation:

10s complement of a decimal number is obtained by the following process:

- Obtain 9s complement ( Subtract each digit by 9)

- Add 1 to the result

1) 123900

9s complement => (9-1)(9-2)(9-3)(9-9)(9-0)(9-0)

= 876099

Adding 1 , 10s complement of 123900 = 876100

2) 980657

9s complement = (9-9)(9-8)(9-0)(9-6)(9-5)(9-7)

= 019342

Adding 1 , 10s complement of 980657 = 019343

7 0
3 years ago
How can one become a world scientist?
Lynna [10]
No need to woory abt age !!! In today's competitive grant world, this phenomenon is exacerbated. It is dangerous to one's funding to go against the trend, and if there is a lab to support and mouths to feed, the disincentives are great. This phenomenon stifles creativity, perhaps far more than biological age does. 
<span>While it is not frequently acknowledged either in the popular press or in scientific literature, a significant fraction of scientific discovery is the result of serendipity (or to put it more bluntly, luck). From the discovery of penicillin by Fleming to the discovery of new ionization techniques such as MALDI that power modern mass-spectrometry based proteomic research, luck has frequently played a big role. Such discoveries are generally attributed to hard work and genius, rather than to luck. Doing so gives the “genius” too much credit and luck too little.
</span><span>Risk taking is where most of the big discoveries in science lie. so takerisks.
</span>enjoy  always specially when you r  working and learn to say no
Learning to say “no” is particularly important for young faculty, who find themselves barraged with such requests, and who can easily get sucked into full-time committee duties. It is wise to step back frequently and ask, “overall, is this work I am doing fun?” If the answer is no, perhaps it is time to revisit and consider diving into a new area.
<span>Note the distinction in this guideline from: “learn to write and present well.”
</span><span>Understanding and conveying the big picture for one's work is perhaps the greatest challenge facing young scientists
</span>That's all I can give.
8 0
3 years ago
Read 2 more answers
Help I don’t even know what class is this.
kvv77 [185]

Answer:

I would say D

Explanation:

7 0
2 years ago
A computer that passes the Turing test might show that
kow [346]
A computer that passes the Turing test might show that has the ability to exhibit intelligence similar to, or indistinguishable from that of a human.
8 0
3 years ago
Which of the following statements describes a work station?
STALIN [3.7K]

Answer:

B) Single-user computer which has a more powerful microprocessor than personal computers

8 0
2 years ago
Other questions:
  • What is the main storage device where the computer stores data?
    15·1 answer
  • Documents on the web stored on web servers are known as web _____.
    6·1 answer
  • In order to make burger a chef needs the following ingredients one piece of chicken meat 3 lettuce leaves 6 tomato slices Write
    8·1 answer
  • What category of sensory receptors are sensitive to touch sound and motion?
    10·1 answer
  • 2. An evil twin attack that broadcasts a legitimate SSID for an unauthorized network is an example of what category of threat? A
    9·1 answer
  • The color gradient is
    6·1 answer
  • Expresa tu reflexión sobre la necesidad de un código de etica para la IA (inteligencia artificial) , oponia sobre los bots en la
    15·1 answer
  • Research and recommend the most appropriate VPN technology. The most likely solution is either an Internet Protocol Security (IP
    5·1 answer
  • What is "mob of the dead"?
    7·1 answer
  • Stacy plans to print her contacts and would like to choose an option that will print select information for each contact in a bu
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!