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...
Create an array list (names) that will hold the names of several hall of fame soccer...
Create an array list (names) that will hold the names of several hall of fame soccer players. 2. Place your name on the screen as the master recorder:              “Master Hall of Fame Recorder: John Paul Jones” 3. Ask the user how many names they would like to record. (input 5 when the program runs) 4. Create a loop that will ask for the “Hall of fame member #1: “, etc Add in the following names: Pele Rooney Maradona Messi...
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...
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.
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...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT