Find utility to locate files on the system

Assignment Help Programming Languages
Reference no: EM133140282

KIT501 ICT Systems Administration Fundamentals - University of Tasmania

Goal

The main purpose of this third practical is to give you further familiarity with the UNIX shell (in particular, bash).

A Login to your ictteach account. Change into kit501 directory.

Remove any existing files or subdirectories under kit501 (unless you really want to keep them).

B Use joe or nano to create three text files which must be named as file1, file2, and file3, respectively.

The content of file1 must be:
Content of file1

(Note: press the Enter key at the end of the line before saving the content)

The content of file2 must be:
Content of file2
(Note: press the Enter key at the end of the line before saving the content)

The content of file3 must be:
Content of file3
(Note: press the Enter key at the end of the line before saving the content)

Use cat to verify the file contents after they have been created.
C Run the following command lines and think about the outputs:

$ ls
$ cat file1 > files
$ ls
$ cat files

$ cat file2 > files
$ ls
$ cat files

$ cat file3 > files
$ ls
$ cat files

Have you seen that redirecting output using > erases any pre-existing content?

Now let's try it again using a different approach to see how you can keep any pre- existing content of a file:

$ ls
$ cat file1 > files
$ ls
$ cat files

$ cat file2 >> files
$ ls
$ cat files

$ cat file3 >> files
$ ls
$ cat files
D It is possible to redirect a group of commands using a single command line:


$ rm files
$ ls
$ (cat file1; cat file2; cat file3) > files
$ ls
$ cat files
E Next, let's try redirecting both input and output. First of all, let's slightly change the content of files:

$ rm files
$ ls
$ (cat file3; cat file2; cat file1) > files
$ ls
$ cat files

$ sort < files
$ cat files

$ sort < files > files_sorted
$ ls
$ cat files_sorted

Can you see what has happened here?
F Redirecting error messages is different.

Ensure that you do not have a file named foo under the current directory. If you do, remove it first.

$ cat foo
$ cat foo 2> errors
$ ls
$ cat errors
G You have previously used the find utility to locate files on the system by specifying a set of criteria. You were told to get rid of the many "Permissions denied" error messages by redirecting them to the null device (/dev/null). What if you want to have a record of all the error messages generated from a find session?

$ find / -name "index.htm" 2> errors
(Note: this command line may take some time to run)

$ cat errors

H Remove the errors file.
I What is the difference between the following command lines:

$ cat file1
$ cat < file1

You see the same output from both command lines. The difference is this: In the first command line, the command cat opens the content of file1, but in the second command line, the shell opens the content of file1 and passes it to cat.
J Ensure that you do not have a file named foo under the current directory. If you do, remove it first. Then try the following two command lines and think about why there is a difference between the outputs of them:

$ cat foo 2> error1

$ cat < foo 2> error2

In the second command line, has the file error2 been created after the command is run?

Pipes
A Follow the exercises in section 1.2 to perform the following actions, and ensure that you understand the outputs.
B $ cat

$ cat

$ cat

$ cat files files files files

|

|

|
sort sort sort


|

|


wc wc


-l

-w
C $ who
$ who
| wc -l

|

wc

 

-l
$ who
$ ls
$ cat | tee userlist

userlist
$ who | tee userlist2

$ ls
$ cat userlist2
D What does the following command line do?

$ cat /etc/passwd | grep "David" | wc -l

Command Substitution

A Perform the following actions.
B $ echo This is a nice day
$ echo "This is a nice day"
$ echo 'This is a nice day' (note the single quotes)
C $ echo This tutorial is held on `date`
(note the back-quotes)

$ echo "This tutorial is held on `date`"

$ echo 'This tutorial is held on `date`'

D $ echo There are `ls | wc -l` files in this dir

$ echo "There are `ls | wc -l` files in this dir"

$ echo There are 'ls | wc -l' files in this dir
(note the single quotes)

$ echo There are \`ls \| wc -l\` files in this dir
E Make two subdirectories (under the current directory) named dir1 and dir2, respectively. Explore the behaviour of the following command line (note the option to tail is a one, not the letter l):

$ cd `find . -type d | tail -1`

You may wish to explore the tail command first.

Attachment:- UNIX shell.rar

Reference no: EM133140282

Questions Cloud

Calculate the total expense to be recognized : The building was acquired on January 1, 2017 at a cost of P60,000,000. Calculate the total expense to be recognized in 2020 profit or loss
Write your first scripts : Purpose of this practical is to give you further familiarity with the UNIX shell - You can try to execute this program by simply typing the shell script name
What amount of consigned inventory should be included : Inventory shipped on consignment to A Company P36,000. What amount of consigned inventory should be included in Emily' December 31, 2010 balance sheet
What is the direct labour cost : What is the direct labour cost, variable manufacturing overhead, and fixed manufacturing overhead budgeted for May, June, and July
Find utility to locate files on the system : Find utility to locate files on the system by specifying a set of criteria. You were told to get rid of the many "Permissions denied" error messages
Calculate diana total cost recovery deduction : Diana does not elect immediate expensing under § 179. She elects additional first-year deprecation. Calculate Diana's total cost recovery deduction
What is the net income for the period : The ending balances of capital stock and retained earnings are P300,000 and P120,000, respectively. What is the net income for the period
How much is the capital balance of mariah at the end : Assuming there is an implied undervaluation or overvaluation of an asset, how much is the capital balance of Mariah at the end of the year
Write permission for a directory : The main purpose of this fourth practical is to give you familiarity with UNIX file permissions - when you want to set permissions explicitly, without worrying

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd