Filter
Filters are commands that are used to filter input or output. These commands by default takes input from keyboard and generates output to standard output where the default input and output can be redirected.
Among the most useful filter tools in UNIX System for finding words in files, include grep, fgrep, and egrep.
grep: It lets us search for a target which may be one or more words or patterns containing wildcards and other regular expression elements.
fgrep: Does not allow regular expressions but does allow us to search for multiple targets.
egrep: Takes a richer set of regular expressions, as well as allowing multiple target searches.
grep
The grep command searches through one or more files for lines containing a target and then prints all of the matching lines it finds.
$ grep room mtg_note
The meeting will be at 9:00 in room 1J303.
$
The following command displays all lines containing the word room.
Note: Multiline search should be enclosed within brackets otherwise grep will treat all others words as filename except the first one.
$ grep chicken *
recipes.ch: chicken with black bean sauce
Recipes.mex: chilaquiles with chicken
$
In the following command, the * replaces the current directory listing and grep looks for the word chicken in all the files. It prints the names of the files where it finds the said pattern.
- c Displays count of number of occurrences - l Displays list of filenames only - n Displays line numbers along with lines - v Displays all but lines matching expression - i Ignores case for matching - h Omits filename when handling multiple files - e exp Specifies expression with this option - N n Displays n lines containing pattern (SCO UnixWare only)
Showing posts with label Unix Commands. Show all posts
Showing posts with label Unix Commands. Show all posts
Tuesday, October 6, 2009
Friday, October 2, 2009
Operating System Introduction - UNIX
Operating System
A set of procedures that enable a group of users to share a computer installation or the computing resources efficiently.
Components of an Operating System
• Process Management
• Memory Management
• I/O System Management
• File Management
• Protection/Security System
Components of a Unix System
• Kernel
• System Libraries
• System Utilities
The UNIX kernel has the ability to load and unload arbitrary sections of kernel code on demand. These loadable kernel modules run in privileged kernel mode, and as a consequence have full access to all the hardware capabilities of the machine on which they run.
Kernel Modules
Module Management -- allows modules to be loaded into memory and talk to the rest of the kernel..
Driver Registration – allows modules to tell the rest of the kernel that a new driver has become available.
Conflict-Resolution – allows different device drivers to reserve hardware resources and to protect those
resources from accidental use by another driver.
The features that account for the popularity of UNIX !
• Time-sharing multi-user operating system
• Multitasking
• Portability with minor changes
• Protection at file and directory level
• Powerful user interface and command structure
• Support to various communications protocols
UNIX File System
Organization of Files in UNIX is in a hierarchical structure of subdirectories
UNIX file is a simply a sequence of characters (not wholly true). It places no restrictions on the structure of the file.
A file contains exactly those bytes that you put into it, be it a source program, executable code or anything else. It neither contains its own size nor its attributes, including the end-of-file mark.
Components of an Operating System
• Process Management
• Memory Management
• I/O System Management
• File Management
• Protection/Security System
Components of a Unix System
• Kernel
• System Libraries
• System Utilities
The UNIX kernel has the ability to load and unload arbitrary sections of kernel code on demand. These loadable kernel modules run in privileged kernel mode, and as a consequence have full access to all the hardware capabilities of the machine on which they run.
Kernel Modules
Module Management -- allows modules to be loaded into memory and talk to the rest of the kernel..
Driver Registration – allows modules to tell the rest of the kernel that a new driver has become available.
Conflict-Resolution – allows different device drivers to reserve hardware resources and to protect those
resources from accidental use by another driver.
The features that account for the popularity of UNIX !
• Time-sharing multi-user operating system
• Multitasking
• Portability with minor changes
• Protection at file and directory level
• Powerful user interface and command structure
• Support to various communications protocols
UNIX File System
Organization of Files in UNIX is in a hierarchical structure of subdirectories
UNIX file is a simply a sequence of characters (not wholly true). It places no restrictions on the structure of the file.
A file contains exactly those bytes that you put into it, be it a source program, executable code or anything else. It neither contains its own size nor its attributes, including the end-of-file mark.
UNIX can be viewed as two major layers
Kernel
Shell
Shell - Acts as an interface between the user and the kernel. The shell is a Command Line Interpreter (CLI).
It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems).
The Sell can be uses as a keyboard interface to the operating system, a vehicle for writing scripts for your own personal use and as a programming language to develop new commands for others.
The most popular shell are – Bourne, Korn, C and Bourne Again Shells.
The Shell typically performs the following activities in each cycle of its execution:
• It issues the $ prompt, and waits for you to enter a command.
• After a command has been entered, the shell scans the command line for some special characters, and then rebuilds the command line after processing is complete
• The command is then passed on to the kernel for execution, and the shell waits for its completion
• The $ prompt appears, and the shell waits for you to enter the next command
Kernel
Shell
Shell - Acts as an interface between the user and the kernel. The shell is a Command Line Interpreter (CLI).
It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems).
The Sell can be uses as a keyboard interface to the operating system, a vehicle for writing scripts for your own personal use and as a programming language to develop new commands for others.
The most popular shell are – Bourne, Korn, C and Bourne Again Shells.
The Shell typically performs the following activities in each cycle of its execution:
• It issues the $ prompt, and waits for you to enter a command.
• After a command has been entered, the shell scans the command line for some special characters, and then rebuilds the command line after processing is complete
• The command is then passed on to the kernel for execution, and the shell waits for its completion
• The $ prompt appears, and the shell waits for you to enter the next command
Labels:
Operating System,
UNIX,
Unix Commands,
UNIX OS
Subscribe to:
Posts (Atom)