Professional Documents
Culture Documents
Unix Exercises
Unix Exercises
Entering Commands
COMMAND DESCRIPTION
Cal shows a calendar of the current month
COMMAND DESCRIPTION
COMMAND DESCRIPTION
Find command is used to search and locate the list of files and directories
find based on conditions
To set or alter the file permissions of a particular file or files
chmod ugo+/- rwx filename : Relative Permission Setting
chmod 777 filename : Absolute Permission Setting
number permission
chmod
4 Read
2 write
1 execute
controls how file permissions are set for newly created files
Procedure
Step 4:set execute permission to the file by typing chmod +x filename in $ prompt
COMMAND DESCRIPTION
Pattern Matching Commands
Lets to search for a target which may be one or more words or patterns
containing wild cards or regular expressions
grep
$ grep unix notes // This command searches the pattern called unix in the file
notes
Egrep Egrep or grep -E is another version of grep or the Extended grep.
This version of grep is efficient and fast when it comes to searching for a
regular expression pattern as it treats meta-characters as is and doesn’t
substitute them as strings like in grep, and hence you are freed from the
burden of escaping them as in grep.
In case of egrep, even if you do not escape the meta-characters, it would treat
them as special characters and substitute them for their special meaning
instead of treating them as part of string.
Fgrep Fgrep or the Fixed grep or grep -F is yet another version of grep which
is fast in searching when it comes to search for the entire string instead
of regular expression as it doesn’t recognize the regular expressions,
neither any meta-characters.
For searching any direct string, this is the version of grep which should
be selected.
Fgrep searches for complete string and doesn’t even recognize special
characters as part of regular expression even if escaped or not escaped.
Like, when meta-characters were not escaped, fgrep searched for the
complete string “(f|g)ile” in the file, and when the meta-characters were
escaped, then the fgrep command searched for “\(f\|g\)ile” all
characters as is in the file
COMMAND DESCRIPTION
wc Prints the number of bytes, lines or words in a file
COMMAND DESCRIPTION
cut To extract specific fields and columns
cut –f : is used to extract specific field of a field structured file
cut –c : is used to extract specific columns of a field structures file
cut –d delimiter –f : to display specific fields with specified delimiter
colrm Deletes one or more columns from a file or set of files
COMMAND DESCRIPTION
cmp Tells whether two files differ , and if they do, it reports the position in
the file where the first difference occurs
Comm. To compare two sorted files and sho lines that are the same or different.
Comm. Prints its output in 3 columns
Lines unique to the first file
Lines unique to the seconf file
Lines found in both
diff Compares two files , line by line, and print out differences
COMMAND DESCRIPTION
date Prints the date in a default format
Date –d : allows to specify a particular time or date to display
bc and dc Used as both calculator and mini-language for writing mathematical
programs
Aim : To illustrate unix awk and sed commands
COMMAND DESCRIPTION
Awk Test for the pattern in every line of input, and to perform the
corresponding action whenever the pattern matches the input line
sed Takes a set of patterns and simple editing commands and applies them
to an input stream