Lecture 8 CT5052 Network Operating Systems PDF
Document Details
Uploaded by WellVuvuzela
Informatics College Pokhara
Tags
Summary
This document is a presentation on CT5052 Network Operating Systems, specifically covering GREP and Aliasing. It details the usage of grep commands, regular expressions, and how to create and manage aliases in a Linux environment. It's geared towards an undergraduate audience.
Full Transcript
Lecture 8 CT5052 Network Operating Systems GREP and Aliasing Regular Expression: Regular Expression provides an ability to match a “string of text” in a very flexible and concise manner. A “string of text” can be further defined as a single character, word, sentence or pattern of ch...
Lecture 8 CT5052 Network Operating Systems GREP and Aliasing Regular Expression: Regular Expression provides an ability to match a “string of text” in a very flexible and concise manner. A “string of text” can be further defined as a single character, word, sentence or pattern of characters. GREP (Global Regular Expression Print) Command: The ‘grep’ command is used to print the lineup text and the regular expressions. Search for a text in a normal file: Command: grep “Brad William” names.txt Usage of ‘-w’ whole word option: Command: grep –w “Brad William” names.txt Avoiding case sensitive: GREP is case sensitive, but we can avoid case sensitive by using the ‘- i’ option. Finding the Line Number: We can use the ‘-n’ option in the grep command for finding the line number of the matched line. Usage of ‘-v’ option: In the grep command, the ‘-v’ option ignores the line of the searched string. Display certain non-matched lines with line containing matched string in GREP Use the -A command line option to print 'N' lines after the matched line. Display certain non-matched lines with line containing matched string in GREP Similarly, the -B command line option is used to display lines before the matched line. Display certain non-matched lines with line containing matched string in GREP To print lines around the matched line, use the -C command line option. Only print matched strings in GREP You are also allowed to only print the matched string on the standard output (instead of complete lines that get displayed by default). This feature can be accessed using the -o command line option. Aliasing: Aliases are like custom shortcuts used to represent a command (or set of commands) executed with or without custom options. List Currently Defined Aliases in Linux You can see a list of defined aliases on your profile by simply executing alias command. Defining an alias temporarily: $ alias shortname=‘your custom command here’ Note: Alias once defined on a shell is just stored for that current running session only. Once, the session is closed the defined alias gets removed and won’t be preserved for another session. Defining an alias permanently: You need to set the alias on the ‘.bashrc’ file which is the configuration file of the bash, to keep the alias preserved in every session. Removing an alias: $ unalias lsl Any Questions? Thank You!!!