Ulp 3 and 4
Ulp 3 and 4
Ulp 3 and 4
Practical No.3
Aim: To familiarize with Linux/Unix grep filter commands.
2. Dot Character(.): The (.) Dot is used to match a single character except a new
line character. (.) Dot is used in regular expression whereas in case of shell operator “?” is
used to match a single character.
2321020
3. Plus character (+): The + character is similar to (*) except that (+) character
matches one or more occurrences of preceding character.
4. Caret character (^): This quantifier is used to search those words that
start with a specified pattern. And it is used for negate the symbol.
5. Dollar character ($): It matches or search those words that ends with
specified pattern.
7. $ls -l | grep “^d”: This command displays the all directories under the current
working directory.
8. $ ls -l | grep “^-rwx”: This command display all the files which have rwx
permission for the user.
9. grep pattern filename : This command is used for searching the single
pattern into the file.
11. Inverse Option (-v): It will print those lines that do not contains specified
patterns.
2321020
12. Ignore option (-i): Grep distinguish between uppercase and lowercase with -I
option it will prints all patterns without considering the case.
14. Count occurrences (-c): The -c option with grep command will count the
occurrences of records.
15.Line number option (-n): This option will print out the line number with
the record that contain the specified pattern.
2321020
16.Multiple pattern search option (-e): This pattern option allows us
to search multiple patterns within a single command.
19. Egrep “e{2}*”: This command is used to search a pattern contains consecutive
“ee” characters.
2321020
20. fgrep ‘^’ greptest3: This command is used to print the result which start
with the ‘^’.
21. fgrep -F ‘^’ greptest: This command is used to print the result which start
with the ‘^’.
22. fgrep ‘$’ greptest: This command is used to print the result which ends with
the ‘$’.
2321020
23. fgrep -F ‘$’ greptest3: This command is used to print the result which ends
with the ‘$’.
24. fgrep ‘$$’ greptest3: This command is used to print the result which ends
with the ‘$$’.
2321020
PRACTICAL-04
AIM: To familiarize with the VI editor.
Theory: The default editor that comes with the UNIX operating system is called vi (visual
editor). Using vi editor, we can edit an existing file or create a new file from scratch. we can also
use this editor to just read a text file.
Syntax: vi filename
Insert mode: This mode enables you to insert text into the file. Everything
that’s typed in this mode is interpreted as input and finally, it is put in the file. The
vi always starts in command mode. To enter text, you must be in insert mode. To
come in insert mode, you simply type i. To get out of insert mode, press the Esc
key, which will put you back into command mode.
q: Quit
q!: Quit without saving changes i.e. discard changes.
r fileName: Read data from file called fileName.
wq: Write and quit (save and exit).
w fileName: Write to file called fileName (save as).
w! fileName: Overwrite to file called fileName (save as forcefully).
2321020
!cmd: Runs shell commands and returns to Command mode.
Save and quit the file: