Question

Linux Q4 (15pt): Write a script that describe every file or directory of current directory. Example...

Linux Q4 (15pt): Write a script that describe every file or directory of current directory.

Example output (input in bold):

Document is directory

Example1 is file

Desktop is directory

… …

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the script code as per mentioned question:

#!/bin/sh
echo current directory path :
echo $PWD
echo Details of directory items :
echo
for file in $(ls $dir)
do
[ -f $file ] && echo "$file is file"
[ -d $file ] && echo "$file is directory"
done

Just create a first.sh file and write the above code in it.

go to that directory using on terminal $ cd Desktop/  

Run the script code by using /Desktop$ sh first.sh

Output is as under:

current directory path :
/home/deepak/Desktop
Details of directory items :

1067514_CV.doc is file
answer is directory
answer.txt is file
CheggIndia is directory
Copy is file
details.csv is file
first.sh is file
IROS_Rejected is directory
market is file
new is directory
note is file
offer_11.png is file
results.out is file
Summary.doc is file

Screenshot of the code and out is attached.

Add a comment
Know the answer?
Add Answer to:
Linux Q4 (15pt): Write a script that describe every file or directory of current directory. Example...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write a script which will list the contents of the /dev directory. Then have the script...

    write a script which will list the contents of the /dev directory. Then have the script create a file to redirect the output from the file to a new directory called Devsample in the /home directoy which will only display first 10 lines of the directory and last 5 lines of the directory. Show the output of the Devsample file. ( LINUX SCRIPT)

  • (In Linux) 1. Create a file to write to from your script and save it as...

    (In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...

  • For Linux Bash Script: Show the crontab file entry that would run the script from the...

    For Linux Bash Script: Show the crontab file entry that would run the script from the last question, every Monday, Wednesday, and Friday at 5:30 AM.  Assume the name of the script is fileCleanup.sh and that it is located in the ~/script directory.

  • LINUX 140U Create a file named script1.sh that contains a bash script that: Accepts NO command...

    LINUX 140U Create a file named script1.sh that contains a bash script that: Accepts NO command line arguments and does NOT use the read command. I will give you no credit if your bash script includes a read command. Also, you need to have at least one for..in loop in your code even if there may be other ways to do this problem. The script will go through a list of entries in the current directory (do not process subdirectories):...

  • Hi I beed this assignment to be in a script in linux from codio. Can someone...

    Hi I beed this assignment to be in a script in linux from codio. Can someone please help me step by step thank you. Overview: In this milestone, you will demonstrate your ability to create a basic script in Linux. Review the Final Project Guidelines and Rubric document to see how this milestone will prepare you for the scripting portion of the project. You will perform this milestone in Codio in the unit called “Milestone 2: Scripting.” You will create...

  • You need to write Linux commands to set up the read, write and execute permissions at...

    You need to write Linux commands to set up the read, write and execute permissions at group level. R_Access_Output: A group that allows read access to the project output file RW_Access_Output: A group that allows read/write access to the project output file. R_Access_InputFile: A group that allows read access to the shell script input file. RW_Access_InputFile: A group that allows read/write access to the shell script input file Script_Execution: A group that should allow executing the script. Login into the...

  • USING Unix/Linux shell !!!: 1) Write a script (project2.sh) that will take information from a file,...

    USING Unix/Linux shell !!!: 1) Write a script (project2.sh) that will take information from a file, and print (user’s choice of printers) identical form letters to each recipient. Either E197, E-199, E-194 printers or to project2.output. Prompt the user for their choice. 2) The script and output file are due: per Moodle timeline. Please upload your fully functioning script (project2.sh) your data file (project2.input) and your output file (project2.output) into Moodle. 3) Requirements of the script. a. You can use...

  • Write the Linux command that will add the current directory to the beginning of the PATH...

    Write the Linux command that will add the current directory to the beginning of the PATH environment variable. Linux Command: Write the command that will create a compressed archive of your Chap12 directory. Name the archive Chap12Backup.tgz Linux Command:

  • Write a bash script to find all the files ending with .c recursively for every directory...

    Write a bash script to find all the files ending with .c recursively for every directory in your current working directory, then copy each one to a folder called programs, need handle duplicates by appending the number to the end of the file (ex main.c main-1.c ) compile them and generate a report report should look like: main.c compiles prog2.c failed main-2.c compiles etc.

  • write the bash script Write a script compress_large_files.sh. This script accepts one or more command line...

    write the bash script Write a script compress_large_files.sh. This script accepts one or more command line arguments. The first argument has to be an integer; let’s call it size. If this is the only command line argument, compress_large_files.sh inspects all files in the current working directory and compresses every file of size at least size. If there is more than one command line argument, all arguments except the first one must be valid directories. In this case, compress_large_files.sh inspects the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT