Question

In: Computer Science

Create files with the following names : test1, test2, test3. Create a symbolic link to test2...

Create files with the following names : test1, test2, test3. Create a symbolic link to test2 and name it test4 Create a directory and name it test5.

Write a shell script to perform the following tasks:

• check if a file named test6 exist. If not, it should create it.

• Display a text to indicate whether test4 is symbolic link or not

• Display a text to indicate whether test2 is directory or not

• Display a text to indicate whether test1 is older than test4

• Display a text to indicate whether tes3 is a character device file or not.

Solutions

Expert Solution

To create the 3 files, we use the touch command as:

touch test1

Then we create the symbolic link using ln command:

ln -s test2 test4

Finally we create directory by:

mkdir test5

Now, we have the following structure before our script:

We have written the following script in script.sh :

SCRIPT:

FILE=test6
#To check if file exists, we use the -f operator
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
echo "$FILE does not exist, creating it."
touch $FILE
fi
#To check if file is a symbolic link & it exists, we use the -L operator
FILE=test4
if [ -L "$FILE" ]; then
echo "$FILE is a symbolic link."
else
echo "$FILE is not a symbolic link."
fi

FILE=test2
if [ -d "$FILE" ]; then
echo "$FILE is a directory."
else
echo "$FILE is not a directory."
fi
# The -ot operator compares if first file is older than the second file specified
if [ "test1" -ot "test4" ]
then
echo "test1 is older than test4."
else
echo "test1 is not older than test4."
fi

FILE=test3
if [ -c "$FILE" ]; then
echo "$FILE is a character device file."
else
echo "$FILE is not a character device file."
fi

Script Output:

(*Note: Please up-vote. If any doubt, please let me know in the comments)


Related Solutions

You are to create a hard link to one of your existing files on someone else's...
You are to create a hard link to one of your existing files on someone else's directory (or vice versa). In other words, you know that you can link a file within your own directories, but you can also have a link to one of your files on other areas of the unix system as long as you have permissions to write to that directory (in this case, your partner). Create a subdirectory called temp where you can place this...
The link to the data is below, just click the link & open up the files...
The link to the data is below, just click the link & open up the files please. Listed under MOISTURE http://www.mediafire.com/download/thnnoaaqqefdwcf/excel_files.zip An important quality characteristic used by the manufacturer of Boston and Vermont asphalt shingles is the amount of moisture the shingles contain when they are packaged. Customers may feel that they have purchased a product lacking in quality if they find moisture and wet shingles inside the packaging. In some cases, excessive moisture can cause the granules attached to...
•What is a symbolic link and why do we care about them with respect to Apache?...
•What is a symbolic link and why do we care about them with respect to Apache? •If you were modifying Apache to run SSL (https), this generally requires that port 443 is open. While you can certainly set up things on the virtual machine to function at port 443, what else would have have to do to observe SSL working on our local machine? (Hint: think port forwarding). •When deploying a module like Dav or Apache, describe the relationship between...
In imitation of "A Paring Knife," create a story in which an object with symbolic meaning...
In imitation of "A Paring Knife," create a story in which an object with symbolic meaning turns up after being lost. Have your character(s) do something with it. Whatever they decide to do will be a symbolic act.
When using random access files in Java, the programmer is permitted to create files which can...
When using random access files in Java, the programmer is permitted to create files which can be read from and written to random locations. Assume that a file called "integers.dat" contains the following values: 25 8 700 284 63 12 50 Fill in blanks: You are required to write the following Java code statements: (a) create a new stream called, blueray, which allows the program to read from and write to the file, "integers.dat." _____________________ (b) Write a statement which...
Graphs with Matplotlib Using the library Matplotlib and the provided data files create the following graphs:...
Graphs with Matplotlib Using the library Matplotlib and the provided data files create the following graphs: I) Pie chart Create a pie chart that shows the percentage of employees in each department within a company. The provided file: employee_count_by_department.txt contains the data required in order to generate this pie chart. II) Line Graph Create a line graph that shows a company's profit over the past ten years. The provided file: last_ten_year_net_profit.txt contains the data required in order to generate this...
JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must...
JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must have elements as follow: first ( value passed will be String ) last ( value passed will be String ) age ( value passed will be Numeric ) The constructor will assign the values for the three elements and should use the "this" keyword Create a function, using "printObject" as the identifier printObject: This function will have three input parameters: allNames , sortType, message...
create a document in microsoft word or excel document which has the following: Fictitious names and...
create a document in microsoft word or excel document which has the following: Fictitious names and addresses of 10 folks including name, address and phone number. Recreate the bike table, which includes bike name, part number and hourly rate Please limit your submission to no more than 2 pages.
in python please Q1) Create a Singly link list and write Python Programs for the following...
in python please Q1) Create a Singly link list and write Python Programs for the following tasks: a. Delete the first node/item from the beginning of the link list b. Insert a node/item at the end of the link list c. Delete a node/item from a specific position in the link list Q2) Create a Singly link list and write a Python Program for the following tasks: a. Search a specific item in the linked list and return true if...
General Instructions Upload Matlab files for Assignment 8 to the appropriate link on Blackboard. Upload final...
General Instructions Upload Matlab files for Assignment 8 to the appropriate link on Blackboard. Upload final Matlab files (YourINITIALSfilename.m), separately. Print program flowcharts, listings (a copy of the Matlab code) and requested sample runs, and submit each on the due date. Deliverables: For each program submit a flowchart, listing of the code, a sample run and the program’s Matlab (.m) file. Problems: 1. The “filename” in YourINITIALSfilename.m for this program is “cylinder”. Create a flowchart and a corresponding Matlab program...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT