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 the sentence in symbolic form

Identify the primitive statements in the sentence "Plate tectonics explains mountain building and continental drift." Assign variable names to the primitive statements, and then write the sentence in symbolic form. (There is more than one primitiv..

  Pascal random number generator

Your assignment is to explore the behavior of your Pascal random number generator by throwing random numbers between 20001 and 380000 (inclusive)

  What is a chief concern of cloud computing

What is a chief concern of cloud computing

  User defined function to calculate average of three scores

A user defined function that will calculate and display the average of the 3 scores that remain after dropping the highest and lowest scores the performer received.

  FIT5197 Modelling for data analysis Assignment

FIT5197 Modelling for data analysis Assignment help and solution, Monash University - assessment writing service - Linear Regression and Anova

  Artificial intelligence include expert systems,neural n/w

Are there ethical concerns here? How about ethical concerns for gathering and using competitive intelligence?

  Program to create professor rating class

Write down program to create Professor Rating class comprising of professor ID and three ratings. Three ratings are utilized to estimate easiness.

  Design logic for application for company to store breakdown

Design the logic for an application for a company that wants a report containing a breakdown of payroll by department. Input includes each employee's last name.

  Write a program segment to figure out all prime numbers

Write a program segment to figure out all prime numbers below 100, store the count of these prime numbers variable countPrimes, store the found prime number.

  Design implement test and debug a program with a jframe

design implement test and debug a program with a jframe that allows the user to enter a series of contacts names ages

  Test a prolog program to simulate a mouse traversing a maze

COMP 333 Midterm Test - Logical programming. Write, execute, and test a Prolog program to simulate a mouse traversing a maze

  Analyze average-case performance of linear search algorithm

Analyze the average-case performance of the linear search algorithm, if exactly half the time the element x is not in the list.

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