Free Essay

Simulation of Grep in Linux

In: Computers and Technology

Submitted By Chandnicj
Words 849
Pages 4
A Final Report On

A C PROGRAM TO SEARCH FOR PATTERN IN VARIOUS FILES WITHOUT USING GREP COMMAND

TABLE OF CONTENTS          Introduction Review of Literature Problem Statement Objectives of the project System flowchart and logical diagram Complete work Plan with timelines Expected outcome of the study Conclusion Bibliography

INTRODUCTION Grep is a powerful tool to search files for some phrase or any expression. Grep searches an input file for lines containing a match to a given pattern list. When it finds a match in a line, it copies the line to standard output (by default). We can redirect the screen output into another file and then manipulate it. Though grep expects to do the matching on text, it has no limits on input line length other than available memory, and it can match arbitrary characters within a line. If the final byte of an input file is not a newline, grep silently supplies one. Since newline is also a separator for the list of patterns, there is no way to match newline characters in a text. The syntax of the Grep command is grep [options] expression [file ( s ) ] which means “global regular expression print” This program deals with searching various patterns from a file without using grep or any other inbuilt command. It also includes searching with the help of regular expression. Besides, some of the options of grep command have also been included.

REVIEW OF LITERATURE Grep is a command-line utility for searching plain-text data sets for lines matching a regular expression. Grep was originally developed for the UNIX operating system, but is available today for all Unix-like systems. Grep was created, in an evening, by Ken Thompson as a standalone application adapted from the regular expression parser he had written for ed (which he also created). In ed, the command g/re/p would print all lines matching a previously defined pattern. Grep's official creation date is given as March 3, 1973, in the Manual for Unix Version with the increasing popularity of regular expression, the text editor “ed” include a functionality using which one can print the lines, in the currently edited file, which matches a regular expression. The main options flags used by grep are: `-c `–count: Suppress normal output; instead print a count of matching lines for each input file. With the `-v‟, `–invert-match‟ option, count non-matching lines. `-n’ `–line-number: Prefix each line of output with the line number within its input file. `-o’ `–only-matching: Print only the part of matching lines that actually matches pattern. `-q’ `–quiet’ `–silent: Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. Also see the `-s‟ or `–no-messages‟ option. `-v’ `–invert-match: Invert the sense of matching, to select non-matching lines. `-x’ `–line-regexp: Select only those matches that exactly match the whole line.

A variety of grep implementations are available in many operating systems and software development environments. Early variants included egrep and fgrep, introduced in version 7 unix . The "egrep" variant applies an extended regular expression syntax that was added to Unix after Ken Thompson's original regular expression implementation. The "fgrep" variant searches for any of a list of fixed strings using the Ahocorasick string matching algorithm. These variants persist in most modern grep implementations as command-line switches (and standardized as -E and -Fin posix). In such combined implementations, grep may also behave differently depending on the name by which it is invoked, allowing fgrep, egrep, and grep to be links to the same program file. Other commands contain the word "grep" to indicate that they search (usually for regular expression matches). The pgrep utility, for instance, displays the processes whose names match a given regular expression. In the perl programming language, grep is the name of the built-in function that finds elements in a list that satisfy a certain property. This higher-order function is typically named filter in functional programming languages. The pcregrep command is an implementation of grep that uses Perl regular expression syntax. This functionality can be invoked in the GNU version of grep with the -P flag. This project performs the task of grep commands without using grep command. In this project we string functions and loops are used.

PROBLEM STATEMENT A C PROGRAM TO SEARCH FOR PATTERN IN VARIOUS FILES WITHOUT USING GREP COMMAND While implementing this project, I faced a few problems. These are discusses below:  For the pattern of type “b[eo]at” , three strings are used:  Str for b  Or for [  Str1 for at When I compiled it for the first time it returned a garbage value, so I had to include some extra step and I assigned a null character at the end of each string.  str[c1]='\0';  or[c2]='\0';  str1[c3]='\0';  For the pattern of type “ya*y”, the our program could not search for the pattern like “yy” so I used a for loop to count the zero occurrence of „a‟ for(j=0;j

Similar Documents

Premium Essay

Intro to Linux

...A Practical Guide to Linux Commands, Editors, and Shell Programming SECOND EDITION ® Mark G. Sobell Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States, please contact: International Sales international@pearson.com Visit us on the Web: informit.com/ph Library of Congress......

Words: 228961 - Pages: 916

Free Essay

Rute Linux Tutorial

...LINUX: Rute User’s Tutorial and Exposition Paul Sheer August 14, 2001 Pages up to and including this page are not included by Prentice Hall. 2 “The reason we don’t sell billions and billions of Guides,” continued Harl, after wiping his mouth, “is the expense. What we do is we sell one Guide billions and billions of times. We exploit the multidimensional nature of the Universe to cut down on manufacturing costs. And we don’t sell to penniless hitchhikers. What a stupid notion that was! Find the one section of the market that, more or less by definition, doesn’t have any money, and try to sell to it. No. We sell to the affluent business traveler and his vacationing wife in a billion, billion different futures. This is the most radical, dynamic and thrusting business venture in the entire multidimensional infinity of space-time-probability ever.” ... Ford was completely at a loss for what to do next. “Look,” he said in a stern voice. But he wasn’t certain how far saying things like “Look” in a stern voice was necessarily going to get him, and time was not on his side. What the hell, he thought, you’re only young once, and threw himself out of the window. That would at least keep the element of surprise on his side. ... In a spirit of scientific inquiry he hurled himself out of the window again. Douglas Adams Mostly Harmless Strangely, the thing that least intrigued me was how they’d managed to get it all done. I suppose I sort of knew. If I’d......

Words: 159689 - Pages: 639

Premium Essay

Ethical Hacking

...Importance of ethical hacking Chapter 1 Introduction Ethical hacking is an emerging tools used by most of the organizations for testing network security. The security risks and vulnerabilities in a network can be recognized with the help of ethical hacking. This research completely concentrates on ethical hacking, problems that may occur while hacking process is in progress and various ethical hacking tools available for organizations. Information is the important source for any organizations while executing business operations. Organizations and government agencies have to adopt ethical hacking tools in order secure important documents and sensitive information (Harold F. Tipton and Micki Krause, 2004). Ethical hacker professionals have to be hired in order to test the networks effectively. Ethical hackers perform security measure on behalf of the organization owners. In order to bring out the ethical hacking efforts perfectly a proper plan must be executed. Ethical hacking has the ability to suggest proper security tools that can avoid attacks on the networks. Hacking tools can be used for email systems, data bases and voice over internet protocol applications in order to make communications securely. Ethical hacking can also be known as penetration testing which can be used for networks, applications and operating systems (Jeff Forristal and Julie Traxler, 2001). Using hacking tools is a best method for identifying the attacks before it effect the entire organization.......

Words: 9223 - Pages: 37

Free Essay

Syllabus

...SCHEME OF EXAMINATION FOR MASTER OF COMPUTER APPLICATIONS (MCA) (SIX-SEMESTER Programme) |Semester – I | |Paper |Title of the Paper |Duration |Maximum Marks |Total | |No. | |Of Exam | | | | | | |Theory |Sessional* | | |MCA-101 |Computer Fundamentals and Problem Solving Using C |3 Hours |80 |20 |100 | |MCA-102 |Computer Organisation |3 Hours |80 |20 |100 | |MCA-103 |Discrete Mathematical Structures |3 Hours |80 |20 |100 | |MCA-104 |Software Engineering |3 Hours |80 |20 |100 | |MCA-105 |Computer Oriented Numerical and Statistical Methods |3 Hours |80 |20 |100 | |MCA-106 |Software Laboratory - I |3 Hours | | |100 | | |C (Based on MCA-101) |...

Words: 13848 - Pages: 56

Free Essay

Blah

...……………………………………………………………………………………………………………………………………. 4 Journal Post (8/17) ……………………………………………………………………………………………………………………………… 13 Chapter 1 Questions …………………………………………………………………………………………………………………………… 14 Journal Post (8/24) ……………………………………………………………………………………………………………………………… 16 Chapter 2 Questions ……………………………………………………………………………………………………………………………. 17 Journal Post (9/7) ………………………………………………………………………………………………………………………………… 18 Chapter 3 Questions ……………………………………………………………………………………………………………………………. 19 Journal Post (9/12) ……………………………………………………………………………………………………………………………… 20 Chapter 4 Questions …………………………………………………………………………………………………………………………… 21 Chapter 5 Questions …………………………………………………………………………………………………………………………… 23 NOS 120 Test 2 …………………………………………………………………………………………………………………………………… 24 Linux File System vs. Windows File System …………………………………………………………………………………………. 27 Journal Post (9/14) ……………………………………………………………………………………………………………………………… 28 10.04 Sources List ………………………………………………………………………………………………………………………………. 29 Things to do after installing Ubuntu 10.04 …………………………………………………………………………………………. 37 Journal Post (9/21) …………………………………………………………………………………………………………………………….. 45 How to make Ubuntu look like a Mac ………………………………………………………………………………………………… 46 Journal Post (9/28) …………………………………………………………………………………………………………………………….. 50 Journal Post (10/6)...

Words: 17866 - Pages: 72

Free Essay

Fsfdfdfd

...Oracle VM VirtualBox R User Manual Version 5.0.0 c 2004-2015 Oracle Corporation http://www.virtualbox.org Contents 1 First steps 1.1 Why is virtualization useful? . . . . . . . . . . . . . . . 1.2 Some terminology . . . . . . . . . . . . . . . . . . . . . 1.3 Features overview . . . . . . . . . . . . . . . . . . . . . 1.4 Supported host operating systems . . . . . . . . . . . . 1.5 Installing VirtualBox and extension packs . . . . . . . . 1.6 Starting VirtualBox . . . . . . . . . . . . . . . . . . . . 1.7 Creating your first virtual machine . . . . . . . . . . . 1.8 Running your virtual machine . . . . . . . . . . . . . . 1.8.1 Starting a new VM for the first time . . . . . . 1.8.2 Capturing and releasing keyboard and mouse 1.8.3 Typing special characters . . . . . . . . . . . . 1.8.4 Changing removable media . . . . . . . . . . . 1.8.5 Resizing the machine’s window . . . . . . . . 1.8.6 Saving the state of the machine . . . . . . . . 1.9 Using VM groups . . . . . . . . . . . . . . . . . . . . . 1.10 Snapshots . . . . . . . . . . . . . . . . . . . . . . . . . 1.10.1 Taking, restoring and deleting snapshots . . . 1.10.2 Snapshot contents . . . . . . . . . . . . . . . . 1.11 Virtual machine configuration . . . . . . . . . . . . . . 1.12 Removing virtual machines . . . . . . . . . . . . . . . . 1.13 Cloning virtual machines . . . . . . . . . . . . . . . . . 1.14 Importing and exporting virtual machines . . . . . . . 1.15 Global Settings . . . . . . . . . . . . . . . . . . . . . ....

Words: 143714 - Pages: 575

Free Essay

Qq Dsfer Dswre

...NEWS for R version 3.0.3 (2014-03-06) NEWS R News CHANGES IN R 3.0.3 NEW FEATURES: • On Windows there is support for making ‘.texi’ manuals using texinfo 5.0 or later: the setting is in file ‘src/gnuwin32/MkRules.dist’. A packaging of the Perl script and modules for texinfo 5.2 has been made available at http://www.stats.ox.ac.uk/pub/Rtools/. • write.table() now handles matrices of 231 or more elements, for those with large amounts of patience and disc space. • There is a new function, La_version(), to report the version of LAPACK in use. • The HTML version of ‘An Introduction to R’ now has links to PNG versions of the figures. • There is some support to produce manuals in ebook formats. (See ‘doc/manual/Makefile’. Suggested by Mauro Cavalcanti.) • On a Unix-alike Sys.timezone() returns NA if the environment variable TZ is unset, to distinguish it from an empty string which on some OSes means the ‘UTC’ time zone. • The backtick may now be escaped in strings, to allow names containing them to be constructed, e.g. \ . (PR#15621) • read.table(), readLines() and scan() now warn when an embedded nul is found in the input. (Related to PR#15625 which was puzzled by the behaviour in this unsupported case.) • (Windows only.) file.symlink() works around the undocumented restriction of the Windows system call to backslashes. (Wish of PR#15631.) • KalmanForecast(fast = FALSE) is now the default, and the help contains an example of how fast = TRUE can be used in this version. (The usage......

Words: 11048 - Pages: 45

Premium Essay

Gsl Scientific Library

...GNU Scientific Library Reference Manual Edition 1.14, for GSL Version 1.14 4 March 2010 Mark Galassi Los Alamos National Laboratory Jim Davies Department of Computer Science, Georgia Institute of Technology James Theiler Astrophysics and Radiation Measurements Group, Los Alamos National Laboratory Brian Gough Network Theory Limited Gerard Jungman Theoretical Astrophysics Group, Los Alamos National Laboratory Patrick Alken Department of Physics, University of Colorado at Boulder Michael Booth Department of Physics and Astronomy, The Johns Hopkins University Fabrice Rossi University of Paris-Dauphine Copyright c 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The GSL Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License” and “Free Software Needs Free Documentation”, the Front-Cover text being “A GNU Manual”, and with the Back-Cover Text being (a) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”. (a) The Back-Cover Text is: “You have the freedom to copy and modify this GNU Manual.” Printed copies of this manual can be purchased from Network Theory Ltd at http://www.network-theory.co.uk/gsl/manual/. The money raised from sales of the......

Words: 148402 - Pages: 594

Free Essay

Gd-Pi

...Hundreds(of(real(personal(accounts(of Group'Discussions'&'Personal'Interviews during(MBA(admissions(to(India’s(best(B9schools Written'by Compiled'by Loads'of'MBA'Aspirants The'PaGaLGuY'MadCapz'Group PaGaLGuY.com Antholo gy Hundreds of real personal accounts of Group Discussions and Personal Interviews during MBA admissions to India’s best business schools. In this edition: The IIMs at Ahmedabad, Bangalore, Calcutta, Lucknow, Indore & Kozhikode. Written by Loads of MBA aspirants Compiled by The PaGaLGuY MadCapz Team PaGaLGuY GD-PI Anthology Copyright © 2011, PaGaLGuY.com All text and content in this document is solely owned by PaGaLGuY.com. Reproduction without permission in any form or means is illegal. Special copy prepared exclusively for mustafa rokerya Get your own Free personalized copy (with your name on it) of this book from http://www.pagalguy.com/books/ What this book is about What is a real IIM interview like? What kind of questions do they ask and what judgments do applicants have to make while answering them? Since 2003, those with real Group Discussion and Personal Interview calls from India’s top bschools have been posting entire and detailed transcripts of their admission interviews immediately after they happen, so that others slotted for later interviews can learn what GDPI is going to be like this year. This book is a collection of dozens of handpicked GDPI experiences from the country’s top bschools during the......

Words: 178933 - Pages: 716