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
Natalka [10]
3 years ago
14

Write a Bash script that takes the name of a file or directory as an argument, 1. reports if it is a directory or a file, and if

the user has read, write and execute permission on the file or directory, and 2. if it is a file, reports the size of the file and the category of the file based on its size. If the file size is greater than 1MB (1048576B), the file is a large file; if the file size is less than or equal to 1MB (1048576B) and the file size is greater than 100KB (102400B), the file is a medium file; otherwise, it is a small file. Use a sequence of if statements on the file name or file size to determine the information. To get the file size, use command du -b and command cut. Read their manual for how to use them.

Computers and Technology
1 answer:
Alla [95]3 years ago
4 0

Answer:

see explaination

Explanation:

#!/bin/bash

mkdir sampleDir #I am just creating sample Directory

touch sampleFile #Creating sampleFile

echo 'Adding some information' >> sampleFile

cat sampleFile

echo "Listing the contents of the current directory:"

ls

file_size_kb=`du -k sampleFile | cut -f1` #Stores file size in KB, 1024KB = 1MB

echo $file_size_kb

if [ -d $1 ]; then

echo "It is a directory"

if [ -w $1 ]; then

echo "It has write permission"

fi

if [ -x $1 ]; then

echo "It has execute permission"

fi

if [ -r $1 ]; then

echo "It has read permission"

fi

if [ $file_size_kb -lt 1024 ]; then

echo "Small file"

elif [ $file_size_kb -gt 1024 ]; then

echo "Large file"

elif [ $file_size_kb -le 1024 && $file_size_kb -ge 1024 ]; then

echo "Medium file"

fi

elif [ -f $1 ]; then

echo "It is a file"

if [ -w $1 ]; then

echo "It has write permission"

fi

if [ -x $1 ]; then

echo "It has execute permission"

fi

if [ -r $1 ]; then

echo "It has read permission"

fi

if [ $file_size_kb -lt 1024 ]; then

echo "Small file"

elif [ $file_size_kb -gt 1024 ]; then

echo "Large file"

elif [ $file_size_kb -le 1024 && $file_size_kb -ge 1024 ]; then

echo "Medium file"

fi

fi

Check attachment for output and screenshot

You might be interested in
Which of the following data structures can erase from its beginning or its end in O(1) time?
jekas [21]

Where all "the following" i can help you but you said which of the folllowing and ther no picture or anything?

3 0
3 years ago
Provide an example of an IT project from your readings, experience, and/or other sources and discuss some of the challenges face
vlada-n [284]

Answer:

kindly check the explanation.

Explanation:

Getting any project to be a successful one is not an easy task at all as many projects failed even before it nears completion stage. The Project Management Institute[PMI] states that only 69% [mean percentage] are able to complete and meet the original goals for and business intent of the project.

The reasons behind this failed IT projects are numerous, few of them are given below:

=> <em>When estimates for the IT project is inaccurate. Th inaccuracy  do cause IT projects to not meet the target. </em>

<em />

<em>=> When the available resources are not enough and there is poor project management it causes the IT projects to fail.</em>

<em />

<em>=> When team members are not diligent. The procrastination of team members do lead to failed projects.</em>

<em />

The ways that such problems can be overcome in order to to achieve successful outcomes is given below;

=> Someone should be held accountable. That is there should be a seasoned and qualify project manager to supervise the project and can be hold accountable for how things turns how to be.

=> The scope of the project should be flexible so that when things changes the plan can also change.

=> Making sure that all the estimates are accurate.

7 0
3 years ago
What are the different types of biometric method used in artificial intelligence?​
Nadusha1986 [10]

Answer:

Different types of biometric method used in AI are

Explanation:

Face Recognition.

Speaker (Voice) Recognition.

Fingerprint Recognition.

Behavioral Biometrics.

Crossmatch – 'Composite' Biometric Authentication.

Tygart Technology – Facial Recognition from Videos.

Onfido – Facial Biometrics.

EyeLock – Iris Recognition.

6 0
3 years ago
What is considered appropriate dress for men and women in the workplace? Select all that apply.
Andrew [12]

Answer:

I guess clean, pressured pants or skirt

and

dress shirts and ties

8 0
3 years ago
Read 2 more answers
What command limits structural changes, such as adding, deleting, or moving sheets, that can be made in a workbook?
Brilliant_brown [7]
The answer is Protect workbook
4 0
4 years ago
Other questions:
  • 11) Write the definition for a child class of Circle named Cylinder. The cylinder should have a double attribute named height. T
    12·1 answer
  • Describe deforestation
    14·1 answer
  • The roman structure that features heavy use of arches and columns is the _______.
    6·1 answer
  • In the following code, what is the first line that introduces a memory leak into the program?
    6·1 answer
  • The fastest way to get help is to type a word or two in the search box.
    7·1 answer
  • adding ______around calculations indicates which calculations should be performed first before following the typical order of op
    6·1 answer
  • 1. In the Entity-Relationship Model, relationships can have attributes.
    11·1 answer
  • ……………………is one of the most popular cloud storage facilities.​
    11·1 answer
  • 11. SQL Output III
    13·1 answer
  • What are the methods of gilding<br><br>nonsense will be immediately reported. ​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!