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
Using this statement to answer the following question “FIFA World Cup 2010: (1+9) From Today!” (Ignore Quotation)
Yuliya22 [10]
Free space going around the town states
5 0
3 years ago
Pls someone help me with these four questions
ipn [44]

Answer:

16. Grace Hopper. 1959.

8 0
3 years ago
Does two core processors mean that it is twice as fast do you agree? why?
vlabodo [156]

Answer:

the friendships the following link and fill out our related information

Explanation:

consisting of a new one of the cell number of people who want

3 0
3 years ago
1. image-editing software
Snezhnost [94]
  • PDF:-Portable Document Format
  • Database software:-software that organizes a collection of information
  • image-editing software :-software used to enhance photographs
  • presentation software :-software used to create a slide show
  • CAD:-software used to create technical drawings.

Done

8 0
2 years ago
What are three ways digital identity is created and kept up? (open answer)
Anna007 [38]

Answer:

Capture attributes as ID documents or biometric data

Explanation:

Examples of such attributes include biometrics, verified identification documents, and third-party verification procedures. To create a trusted digital ID, there are typically three steps: capturing verified attributes, verification of the documents, and digitization of the ID.

Great day :) toodles

6 0
2 years ago
Other questions:
  • Consider the program below: public class Test { public static void main( String[] args ) { int[] a; a = new int[ 10 ]; for ( int
    5·1 answer
  • PLEASE HELP. I’ll mark you BRAINLIST <br> Please read the comment under this question
    9·1 answer
  • Which of the following scenarios describes an IT professional using the Internet and computer system access in an unprofessional
    7·1 answer
  • How to identify mistakes in a html code??​
    14·1 answer
  • ...................is a high level, structured , open source programming language​
    10·1 answer
  • How do I indent the 1. bullet so it is not lined up with the regular bullet above it?
    9·1 answer
  • You were just hired as an IT Specialist for Smalltown School District. Your first assignment is to review a problem area&amp; in
    11·1 answer
  • . Write a function sumLastPart which, only using list library functions (no list comprehension), returns the sum of the last n n
    6·1 answer
  • 2. Explain the difference between a JMP instruction and CALL instruction
    6·1 answer
  • The variable points stores data that the user has input. what is the data type of this variable?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!