Home | Contact Us | Sitemap
DWHlabs provides Data Warehouse education services.This web portal is very useful to the Database professionals,
Data Warehouse professionals, UNIX professionals etc.,
  About Us Advertise Support us Tell your Fren Testimonial Contact Us  
 
 
Please help us continue development of this website and it's services!
 
 

 


 
UNIX Lab -15 DAYS TUTORIAL - SEVENTH DAY
Sponsered Links
 
 
 
 
 
 
 
  Filter Commands
   

$ grep ::Gloabally Search a Regular expression and print it.

This command is used to search a particular pattern(single string ) in a file or directory and regualr expression(pattern which uses wild card characters).

syntax - $grep pattern filename
eg. $grep dwhlabs dwh (It displays all the lines in a file which as dwhlabs pattern/string) - Character Pattern
eg. $grep "dwhlabs website" dwh - character pattern
eg. $grep \< dwhlabs\> dwh (It displays all the line in a file which as a exact word 'dwhlabs') - Word Pattern
eg. $grep ^UNIX$ language (It displays all the lines in the file which has a single word 'UNIX' ) - Line Pattern

$grep options

$grep -i pattern filename (ignore case sensitive)

$grep -c pattern filename (It displays total count of lines)

$grep -n pattern filename (It displays along with the line number)

$grep -l pattern filename (It displays filename in the current directory)

$grep -v pattern filename (It displays unmatched pattern lines)

Question ?
Q)How to remove blank lines in a file?
A)$grep -v "^$" file1>tmp | mv tmp>file1

Explanation :: Piping concept is used to combine more than one cammand.Here we first identifing the non blank files in file1 and redirecting the result to tmp (temporary file).This temporary file is input to the next command. Now we are renaming the tmp into file1.Now check the file1 result <You will not find any blank lines>

fgrep ::

This command is used to search multiple strings or one string but not regular expression.

syntax - $fgrep "pattern1
>pattern2
>....
>patternn " filename

eg.$fgrep "unix
>c++
>Data Warehouse" stud

egrep :: Extended grep

This command is used to search for single or multiple patterns and also regular expressions.


 
DWH 3Colors
CERTIFICATION GUIDE
DATA DICTIONARY
ALL ARTICLES
   
Data Warehouse Lab

- ETL TOOL
INFORMATICA
OTHER TOOLS

- REPORTING TOOL

BUSINESS OBJECTS
OTHER TOOLS

Database Lab

- ORACLE
SQL
PL/SQL

- DB2
OTHER TOOLS

Unix Lab

Project Lab

DWH Schools

Books Store



 
  About Us Advertise Support us Tell your Fren Testimonial Contact Us  
© 2008 DWHlabs
Privacy Policy | Terms & Conditions