Professional Documents
Culture Documents
Task to be done:
• Enlist all files that start with f and have i or R as second character and
end with a number from range 0-6. Write a command to search the
word Good or good and have any integer from 0-9 at the end of that
word. Exemplify egrep and fgrep for searching above pattern. List all
files starting with word File and having any digit as fifth character and
nothing else. List all files starting with a letter and ending in a number.
• Create a file using vi editor named filters.txt. Enter the content in that
file as follows:
“Anyone who has never made a mistake has never tried anything
new.”
Albert Einstein
After creating a file, count the characters only of a file. Sort the
contents and check if there is any duplicate content exists. After that,
display the line numbers using cat command. Check the occurrences
of word “has” using quantifiers. Search a word “never” which is
preceded by a word “made” and replace it with a word “NEVER”.
• Concept used:
These are some commands and concepts that were being discussed during
the
Lecture time.
or
s- [search]
p- [print]
d- [delete]
g- [global declaration]
-i [ignore the case]
-n [no. of lines]
wildcards-
^ [starts with the word] [^a] [ find out the file in dir = ls ^s]
+ [one or more occurance] [a+le]
* [0 or more occurance]
[ ] [range of occurances]
// Regular expression //
grep
egrep
fgrep
Question (1):
Step 2: To enlist all files that start with f and have i or R as second
character and end
Step 3: To search the word Good or good that have any integer from
0-9 at the end of
Step 5: To list all files starting with word ‘file’ and having any digit
as fifth
Step 6: To List all files starting with a letter and ending in a number
use-
vi filters.txt
Step 3: Now press ‘i’ to enter insert mode and then add the content
wc -c filters.txt
commands)
• Result/Output/Writing Summary:
Fig.5(listing file that starts with alphabet and ends with integers)