LINUX 140U
Create a file named script1.sh that contains a bash script that:
Please let me know if you need more information:-
==========================================
ss139t@ss139t:~/q78$ cat script1.sh
#!/bin/bash
current_directory="."
for name in $(ls "${current_directory}");do
if [ "$name" == "$0" ];then
echo "$name is the script file!"
elif [ -f $name ];then
if [ ! -x $name ];then
#echo "$name is file and not executable"
echo "File content: `cat $name | grep -v 'delete this'`"
#else
# echo "$name is file but executable"
fi
elif [ -d $name ];then
echo "$name is directory"
fi
done
ss139t@ss139t:~/q78$
==============
OUTPUT OBSERVATIONS:-
=========
ss139t@ss139t:~/q78$ ls -ltr
total 44
-rwxr-xr-x 1 ss139t ss139t 0 Mar 16 08:51 file1
-rwxr-xr-x 1 ss139t ss139t 0 Mar 16 08:51 file3
-rwxr-xr-x 1 ss139t ss139t 0 Mar 16 08:51 file6
-rwxr-xr-x 1 ss139t ss139t 0 Mar 16 08:51 file8
-rw-rw-r-- 1 ss139t ss139t 0 Mar 16 08:51 file9
-rwxr-xr-x 1 root root 0 Mar 16 08:52 file12
-rwxr-xr-x 1 root root 0 Mar 16 08:52 file13
-rwxr-xr-x 1 root root 0 Mar 16 08:52 file15
drwxr-xr-x 2 root root 4096 Mar 16 08:52 755
drwxr-xr-x 2 root root 4096 Mar 16 08:52 sample
drwxr-xr-x 2 root root 4096 Mar 16 08:52 sample2
-rw-rw-r-- 1 ss139t ss139t 27 Mar 16 09:21 file7
-rw-r--r-- 1 root root 28 Mar 16 09:22 file10
-rw-r--r-- 1 root root 28 Mar 16 09:22 file14
-rw-rw-r-- 1 ss139t ss139t 27 Mar 16 09:22 file2
-rw-rw-r-- 1 ss139t ss139t 27 Mar 16 09:22 file4
-rw-rw-r-- 1 ss139t ss139t 27 Mar 16 09:22 file5
-rw-r--r-- 1 root root 263 Mar 16 09:24 file11
-rwxr-xr-x 1 ss139t ss139t 433 Mar 16 09:26 script1.sh
ss139t@ss139t:~/q78$
===============
ss139t@ss139t:~/q78$ cat file11
I am file content of file11
I am file content of file11
I am file content of file11
I am file content of file11
I am file delete this content of file11
I am file delete this content of file11
I am file content of f delete this ile11
I am file content of file11
================
ss139t@ss139t:~/q78$ bash script1.sh
755 is directory
File content: I am file content of file10
File content: I am file content of file11
I am file content of file11
I am file content of file11
I am file content of file11
I am file content of file11
File content: I am file content of file14
File content: I am file content of file2
File content: I am file content of file4
File content: I am file content of file5
File content: I am file content of file7
File content:
sample is directory
sample2 is directory
script1.sh is the script file!
==
==
==
Please let me know if you need more information.
===
Thanks
LINUX 140U Create a file named script1.sh that contains a bash script that: Accepts NO command...
(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 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.
Write a bash shell script to carry out each of the following tasks: What to Do: a. Safe Delete: When you use the “rm” command in Linux, it will delete the specified files, with no chance for recovering them back later. Write a script (called srm) that will safely delete the files passed to it as command-line arguments. For example, typing the command: “srm file1 file2 file3”, the script shall not actually delete these files, but instead it shall move...
I need help with this. 22. Show a command that will create a file named "etc.tar" in your home directory from recursively going through all of the files in the "/etc" directory. In other words, the "etc.tar" file will include the files in the "/etc" directory as well as all of its subdirectories. IMPORTANT: This command must work for any user as well as work from any directory. 23. In bash, multiple commands can appear on a single command line...
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...
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...
Write a bash shell script, deleteFilesWithZeroLength.sh, that removes all zero length ordinary files in the directory passed as an optional argument. If you do not specify the directory argument, the script uses the present working directory as the default argument. Do appropriate exception handling in your script such as:If the arguments are more than 1, print out “Too many arguments passed”.If the argument passed is a regular file, print out “XXX is regular file”.1c. If the directory doesn’t exist, print out “Directory...
Programs/scripts 13. Write a bash shell script that displays the date by using the shell command date. 14. Write a command line program that takes a number and a command as arguments. Call that command that number of times. For example, if your program name is "test" test 3 dir <shows directory> dir <shows directory> dir <shows directory>
Write a shell script called GetMyStuff.sh that will provide the above information (the script must be a executable, and must work regardless of which directory it is in). Also, just saying cat MyStuff.txt is not sufficient. (1.0%) A pipeline is the combination of at least 2 commands, where the output of command1 is the input for command2. The syntax is command1 | command2 where | is the pipeline operator. Read the man pages about the ls and wc commands. Devise...