removing unneeded information from grep?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers removing unneeded information from grep?
# 8  
Old 08-20-2001
There exist another way :
cat filename | grep regexp | sed -e "s/.*regexp.*/regexp/g" > outputfile

But your aim is not quiet clear. M.b you simply interested in fact of presence of some regexp in a paticular file. In this case you may simply use grep with "-c" key.



Last edited by CurrentUser; 08-20-2001 at 12:14 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed / awk / grep to extract information from log

Hi all, I have a query that runs that outputs data in the following format - 01/09/12 11:43:40,ADMIN,4,77,Application Group Load: Name(TESTED) LoadId(5137-1-0-1XX-15343-15343) File(/dir/dir/File.T03.CI2.RYR.2012009.11433350806.ARD) InputSize(5344) OutputSize(1359) Rows(2) Time(1.9960)... (8 Replies)
Discussion started by: jeffs42885
8 Replies

2. Solaris

Remove unneeded Ethernet devices?

Solaris 10 x86 VM was shipped with four NICs, two each teamed together. We don't want or need. I ifconfig downed e1000g2 and e1000g3 and removed their /etc/hostname.* entries. But the kernel still sees those devices, and I'm not sure how to remove them. They have been removed from the VM... (5 Replies)
Discussion started by: jnojr
5 Replies

3. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies

4. Shell Programming and Scripting

Include information in certain columns using grep and awk

HI all, I have data in a file that looks like this: 1 HOW _ NNP NNP _ 3 nn _ _ 2 DRUGS _ NNP NNP _ 3 nn _ _ 3 ACT _ NNP NNP _ 0 null _ _ 4 : _ ... (3 Replies)
Discussion started by: owwow14
3 Replies

5. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

6. UNIX for Dummies Questions & Answers

Grep from pattern file without removing duplicates?

I have been using grep to output whole lines using a pattern file with identifiers (fileA): fig|562.2322.peg.1 fig|562.2322.peg.3 fig|562.2322.peg.3 fig|562.2322.peg.3 fig|562.2322.peg.7 From fileB with corresponding identifiers in the second column: NODE_0 fig|562.2322.peg.1 peg ... (2 Replies)
Discussion started by: Mauve
2 Replies

7. UNIX for Dummies Questions & Answers

Grep? - using a file of terms to search another file when the information is on a different line

I have a flat file that looks like this, let's call it Chromosome_9.txt: FT /Gene_Name="Guanyl-Acetylase 9" FT /Gene_Number"36952" FT /Gene_Name="Endoplasmic Luciferase" FT /Gene_Number"36953" FT ... (4 Replies)
Discussion started by: Twinklefingers
4 Replies

8. Shell Programming and Scripting

Grep'ing information from a log file on SUN OS 5

Hi Guys, I'm trying to write an script that will be launched by a user. The script will look at a log file and check for alerts with the date (supplied by user) and a machine's hostname (also supplied by the user). I'm trying to get the output formatted just like the log file. The logfile looks... (5 Replies)
Discussion started by: illgetit
5 Replies

9. Shell Programming and Scripting

copying file information using awk & grep

Hi, TASK 1: I have been using this code to print the information of files kept at "/castor/cern.ch/user/s/sudha/forPooja" in some text file name FILE.txt. rfdir /castor/cern.ch/user/s/sudha/forPooja | grep data | awk '{print "rfio:///castor/cern.ch/user/s/sudha/forPooja/"$9}' > FILE.txt ... (6 Replies)
Discussion started by: nrjrasaxena
6 Replies

10. UNIX for Advanced & Expert Users

How to perform Grep on many Gzip files, Searching for Specific information

Hello, I am wondering if you can assist with my question and ask kindly for this. I have a number of files that are listed as file1.gz through file100.gz. I am trying to perform a grep on the files and find a specific date that only resides within within one of the files. There are... (3 Replies)
Discussion started by: legharb
3 Replies
Login or Register to Ask a Question
DLOCATE(1)							      dlocate								DLOCATE(1)

NAME
dlocate - program to view debian package information SYNOPSIS
dlocate [OPTIONS] [command] [ package... | PATTERN...] DESCRIPTION
dlocate is a fast alternative to dpkg for queries like `dpkg -L' and `dpkg -S' COMMANDS
(none) List all records where either the package name or the filename matches PATTERN. Note that dlocate uses GNU grep, so normal regexp metacharacters need to be taken into account or avoided by using the '-F' (Fixed String) grep option. For example, to search for `/usr/bin/[', you might try: dlocate '/usr/bin/[' or dlocate -F '/usr/bin/[' -S list all records where only the filename matches PATTERN. Note that dlocate uses GNU grep, so normal regexp metacharacters need to be taken into account. Fixed String searches are incompat- ible with -S For example, to search for `/usr/bin/[', you need to type: dlocate '/usr/bin/[' -l Regexp-enhanced emulation of `dpkg -l'. Shows all packages which match package. Internally this uses grep on a file containing the reformatted output output of 'dpkg -l' (four fields separated by tabs; status, package-name, installed version, short description) so it will return packages whose version or short description matches, too. Various flavours of regular expression are supported. For example, Extended Regexp: dlocate -l '^..[[:space:]]libc6' or Perl Regexp: dlocate -P -l '^..slibc6' Both of these will list all the packages whose names start with `libc6'. Note that because of the difference between regular expressions and dpkg's shell-style pattern matching, the output from dlocate -l is occasionally different to the output from dpkg -l. This is not a bug, regular expressions are far more flexible than shell pattern matching. This is the way dlocate is supposed to run, but it may require some knowledge of regular expressions to get the output you want. -k List package names of installed kernels and all related packages -K Detailed list of installed kernels and all related packages -L List all files in package. -s Print status of package. -ls `ls -ldF' of all files in package. -lsconf `ls -ldF' of conffiles in package. -conf List conffiles in package. -du `du -sck' of all files in package. -md5sum List md5sums (if any) of package. -md5check Check md5sums (if any) of package. -man List man pages (if any) in package. -lsman List full path/filenames of man pages (if any) in package. -lsbin List full path/filenames of executable files (if any) in package. OPTIONS
--filename-only Only output file names when searching for files --package-only Only output package names when searching for files -w, --word-regexp Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or fol- lowed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore. -i, --ignore-case Ignore case distinctions in the PATTERN -E, --extended-regexp Interpret PATTERN as an extended regular expression. This is the default. -F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. -G, --basic-regexp Interpret PATTERN as a basic regular expression. -P, --perl-regexp Interpret PATTERN as a Perl regular expression. This is considered to be highly experimental within GNU grep and may warn of unim- plemented features. -h, -H, --help Produces a short help message and exits. -V, --version Display dlocate's version number and exit. -v, --verbose, --debug Produce verbose debugging output FILES
/etc/default/dlocate Configuration file with default options. Currently the only option is to enable/disable gzip compression of /var/lib/dlocate/dlo- catedb. /var/lib/dlocate/dlocatedb plain text listing of all files belonging to all packages (optionally compressed) /var/lib/dlocate/dpkg-list Listing of all packages known to dpkg. This contains the reformatted output output of 'dpkg -l'. The file format is four fields separated by tabs: status [TAB] package-name [TAB] installed version [TAB] short description EXAMPLES
To find which package `/usr/bin/[' belongs to: dlocate '/usr/bin/[' To view all man pages contained within the dpkg package: man $(dlocate -man dpkg) To purge kernel version 2.6.28.7 and all related module packages: dlocate -k | grep -- -2.6.28.7 | xargs apt-get purge To check the md5sums of the dlocate package: dlocate -md5check dlocate To use dpkg-repack to make a backup copy of all installed mythtv packages just before upgrading them: dlocate -l mythtv | grep '^.i' | awk '{print $2}' | xargs dpkg-repack # dlocate -l mythtv | grep '^.i' | awk '{print $2}' | xargs dpkg-repack dpkg-deb: building package `libmythtv-perl' in `./libmythtv-perl_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv' in `./mythtv_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv-backend' in `./mythtv-backend_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv-common' in `./mythtv-common_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv-database' in `./mythtv-database_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv-doc' in `./mythtv-doc_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv-frontend' in `./mythtv-frontend_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv-perl' in `./mythtv-perl_0.21.svn20090414-0.0_amd64.deb'. dpkg-deb: building package `mythtv-status' in `./mythtv-status_0.9.0-5_amd64.deb'. dpkg-deb: building package `mythtv-themes' in `./mythtv-themes_0.21-0.0_amd64.deb'. dpkg-deb: building package `mythtvfs' in `./mythtvfs_0.5.2-2_amd64.deb'. dpkg-deb: building package `python-mythtv' in `./python-mythtv_0.21.svn20090414-0.0_amd64.deb'. ENVIRONMENT VARIABLES
COLUMNS Sets the number of columns dlocate should use when displaying formatted text. Currently only used by -l. Values lower than 80 are ignored. SEE ALSO
dpkg(1), update-dlocatedb(8), grep(1) and grep-dctrl(1). AUTHOR
dlocate was written by Jim Pick <jim@pick.com> and Craig Sanders <cas@taz.net.au>. dlocate is Free Software licensed under the GNU General Public License. Debian Project 2009-06-03 DLOCATE(1)