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...
Problem 1 Write a BASH script to create a user account from the Linux system on which your script is run. The script should process two positional parameters. First positional parameter is supposed to be a string with a user name (e.g., user_name) Second positional parameter is supposed to be a string with a user password (e.g., user_password) In your script: Check if two positional parameters were passed to your script when it was invoked If NOT, print an appropriate...
(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.
LUNIX (Please Label) Exit vi (:q) and from the command line, type viscript4.sh. 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...
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...
Write a bash script question.sh that accepts one command line argument which is supposed to be a positive integer n. The script should print all odd integers from 1 through n. Write a C or C++ program question.c(pp) to read from stdin as many integers as there are available and then print the squares of all these integers. You should test your code by “./question.sh <n> | ./question” assuming the compiled C/C++ program is question. See the following for 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...