Question

LUNIX (Please Label) Exit vi (:q) and from the command line, type viscript4.sh. For this script,...

LUNIX (Please Label)

  1. Exit vi (:q) and from the command line, type viscript4.sh.
    1. For this script, we will iterate through all files in the current directory print out their name using the for loop. Example (do not type yet):

foriin*;do …;done

where the…does some operation on$I, which stands for the current file.

To do this, enter the following in your script4.sh file:

          #!/bin/bash
          for i in *; do

               echo $i

          done

Once the above works, change the for loop to be foriin`ls$1/*`;do. Now when you run the script ,you are expected to pass a directory name asa parameter. Run the script on /etc. Since you are not root, you will not have access to all of the files and directories, but ignore any error messages. Let’s concentrate on just the number of files that are executable. Rerun the script and pipe the result to wc–l to find out how many files/directories matched.  Note: the -l is the letter l, not the number 1.  5) What was the output?

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

#!/bin/bash
for i in `ls $1/*`
do
echo $i
done

if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , before giving thumbs down please discuss the question it may possible that we may understand the question different way and we can edit and change the answers if you argue, thanks :)

Add a comment
Know the answer?
Add Answer to:
LUNIX (Please Label) Exit vi (:q) and from the command line, type viscript4.sh. For this script,...
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
  • 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):...

  • Copy/Paste your script from 5b here. 4. Let's look at a more complicated script executable. a....

    Copy/Paste your script from 5b here. 4. Let's look at a more complicated script executable. a. Write the following as script6.sh and change its permissions to count for num in d do if num eq 100 then count (count+1) done echo The number 10 was found $count times What is the output? Run the script as ./script6.sh 10 20 30 10 40 20 50 10 60 <enter Summarize what the script does r using the read command. The following script...

  • I am having trouble on what exactly to write so I can make the script work,...

    I am having trouble on what exactly to write so I can make the script work, can someone show how to properly do it? Use the vi editor to enter the following script (name this file testscript): #!/bin/bash #script to demonstrate : reading arguments from a command line & # interactively from within script # selection (if… then… else…. fi) # iteration (for loop) # USE FILES ENTERED ON THE COMMAND LINE echo The script you are running is $0...

  • Revision Question 3 on Linux. Please explain the shell script commands in the context of post...

    Revision Question 3 on Linux. Please explain the shell script commands in the context of post execution. You have just logged in and have a directory called "novel" in your home directory containing the following files: chapter1.docx chapter2.docx chapter3.docx draft.pdf save where "save" is itself a directory and contains the files Attributes.txt draft.pdf.1 draft.pdf.2 draft.pdf.3 indexA.txt indexB.txt list1.txt list2.txt a) Describe the results you would expect when executing the following shell commands: i) ls novel/save/*A* ii) ls novel/*r[23]* iii) rmdir...

  • 1. Install the supplied bash script on the Kali Linux VM BASH filename :ipLAN In text...

    1. Install the supplied bash script on the Kali Linux VM BASH filename :ipLAN In text editor looks like this #!/bin/bash is_alive_ping() {    ping -c 1 $1 >/dev/null 2 >&1    [ $? -eq 0 ] && echo Node with IP: $1 is UP. } for i in 192.168.1.{1..255} do is_alive_ping $1 & disown done QUESTION: Install the supplied bash script on the Kali Linux VM **NOte how do i install the above script in kali ,when i am...

  • Objective : Write a C Shell script which copies all files(*.java and *.class) from your home dire...

    Objective : Write a C Shell script which copies all files(*.java and *.class) from your home directory to a new one, and Analyze the new directory information such as number of files, user permissions, and disk usage. Sample Output:                                                    << CS Directory Analysis >>      Date:   ============================================================ Current Directory: /home/tomss New Directory Created : /home/tomss/pgm01 File information Total Number of files : 22 files Directory files:   0 files Plain text files:   10 files File have read permissions: 3 files File have...

  • 5.Create two files also called file file1 and file2 in testdir_2 Use the ls -lR to show you created the directories 6. Change the permission of the files in the directories below and show their permi...

    5.Create two files also called file file1 and file2 in testdir_2 Use the ls -lR to show you created the directories 6. Change the permission of the files in the directories below and show their permissions testdir/testdir_1/file1 where owner has read and execute permissions testdir/testdir_1/file2 where where owner has read, write and execute permissions. Group has read only permissions 7. Create a directory called newdir/newdir_1/newdir_2 copy the file testdir/testdir_1/file1 to this directory Change the permisions of the file to owner,...

  • 1. Write 4 simple shell scripts. Each question will ask you to write one or more...

    1. Write 4 simple shell scripts. Each question will ask you to write one or more command lines to solve a problem. Put the command(s) from each problem into a file named problem1.sh, problem2.sh Note that if you want your script to be interpreted by bash, each file should start with the line: #!/bin/bash and will have one (or more, as needed) commands following it. To execute each script in bash, so you can determine if it is working or...

  • A filename con comprise multiple embedded dots (e.g., a.b.c.d.e). True False A device file is not...

    A filename con comprise multiple embedded dots (e.g., a.b.c.d.e). True False A device file is not really a stream of characters and doesn't contain anything at all. True False Relative pathnames begin with the root directory. True False Running the ls -a command uniquely identifies directories and binary executables. True False What is the result of running mkdir -p share/man/cat1 from the command line? a. It creates the directory share. b. It creates the directory share/man. c. It creates 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
ADVERTISEMENT