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
What term describes one or more characters following the last period in a filename, such as .exe, .txt, or .avi?
elixir [45]

Answer:

Explanation:

.exe: is a file extension, means file that contain executable program which can be run by Microsoft windows.

.txt: is also file extension which contains text (characters).

.avi: means (audio video interleave) is a file extension, which contains audio and video data encoded.

3 0
3 years ago
Why electronic file organization is a key skill for today's workplace ​
Rufina [12.5K]
(I am not sure what you are asking since question is not specific enough),
I am assuming you are asking why organizing a file on a computer is a key skill-

It is because today’s workplace should have as much organization as possible for a steady workplace and work environment, making needed files easy to access.
3 0
3 years ago
How is cropping different from scaling?​
Keith_Richards [23]

Answer:

Scaling changes the size of the whole image by resampling it(duplicating the pixels). in cropping you only get a part of the original image/ remove the outer area of it .

Explanation:

8 0
3 years ago
Mike wanted to create a display that compared data from his research. He should create a _____.
Aliun [14]
Tableeeeeeeeeeeeeeeeeee
7 0
3 years ago
Read 2 more answers
Is majority intent determined by how many times the same type of result is shown on the search engine result page?
laila [671]

According to the search engine algorithm, it is <u>True</u> that the majority intent is determined by how many times the same result is shown on the search engine result page.

<h3>What is Search Intent?</h3>

Search Intent is a term used to describe a user's reason when typing a question or words into a search engine.

Generally, if a user found that no search results match his wants, he would likely not click on any link before performing a similar query search. This would make search engines return with more links that have higher clicks.

<h3>Different types of Search Intent</h3>
  • Informational
  • Commercial
  • Navigation
  • Transactional

Hence, in this case, it is concluded that the correct answer is True.

Learn more about Search Engine here: brainly.com/question/13709771

8 0
3 years ago
Other questions:
  • What is the meaning of "At work, I am quite reserved."?
    15·2 answers
  • The purpose of the ________ element is used to configure the headings for a web page document or section of a web page document.
    11·1 answer
  • What is the only language a microprocessor can process directly but most programmers almost never write programs in this code? Q
    12·2 answers
  • A merge is _____.
    5·2 answers
  • I cannot figure out how to cancel my Brainly subscription. I can’t click “account settings” and “cancel subscription” cuz when I
    5·2 answers
  • A _______ area network is a type of wireless network that works within your immediate surroundings to connect cell phones to hea
    9·2 answers
  • Why is the following statement true - ideally, your information is abbreviated
    10·2 answers
  • Help teacher said with complete explanation ​
    5·1 answer
  • Which is a connectionless protocol in the transport layer? What are the small chunks of data called?
    12·2 answers
  • Software piracy is acceptable as it helps us obtain software cheaper or sometimes even for free.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!