Sponsored Content
Top Forums Shell Programming and Scripting grep 1000s of files with 1000s of grep values Post 302722315 by mantis on Friday 26th of October 2012 06:13:42 PM
Old 10-26-2012
Thank you so much fellas. Been so busy own been able to try your suggestions today.

Regarding the paralellism that is a great idea, problem is I have to put a condition after the grep eg:

Code:
grep -f /path/to/file1  $fname >> /path/to/result  &
        if [ $? = 0 ];
        then
        cp -p $fname $PATH
        fi


But this wont work correctly because of the & which will always be correct. So how do I use parallelism in a script like this?

Thanks again.
Mantis

Last edited by Franklin52; 10-27-2012 at 01:09 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep a list of values

Hi everybody! :) :D :D :) it's great to be here since this is my first post. touch /base/oracle/FRA/XMUT00/RMAN_FLAG touch /base/oracle/FRA/XRLL00/RMAN_FLAG find directory name containing RMAN_FLAG : $ find /base/oracle/FRA -name RMAN_FLAG -print|xargs -n1 dirname |sort -u... (3 Replies)
Discussion started by: jolan_louve
3 Replies

2. UNIX for Dummies Questions & Answers

grep using ASCII values

machine: HPUX file: a.dat contents: decimal 1 decimal 2 string 1 string 2 ASCII value of 'd': 100. to grep lines that have 'd', I use the following command grep d a.dat My requirement: I should grep for lines that contain 'd'. But I should use ASCII value of 'd' in the command... (1 Reply)
Discussion started by: sriksama
1 Replies

3. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

4. Shell Programming and Scripting

grep two values together.

Hi... I have a file abc.txt , havin more then 10,000 lines, each field separated by '#'. I want to grep 9914699895 and 999 from abc.txt I am trying cat abc.txt | grep 9914699895 | grep 999 but i am also getting data like 9991111111 or 9991010101 I want to grep "999" exactly and... (1 Reply)
Discussion started by: tushar_tus
1 Replies

5. UNIX for Advanced & Expert Users

Moving 1000s of files to another folder

Hi, I need to move 1000s of files from one folder to another. Actually there are 100K+ files. Source dir : source1 Target dir : target1 Now if try cp or mv commands I am getting an error message : Argument List too long. I tried to do it by the time the files are created in the... (1 Reply)
Discussion started by: unx100
1 Replies

6. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

7. Shell Programming and Scripting

grep distinct values

this is a little more complex than that. I have a text file and I need to find all the distinct words that appear in a line after the word TABLESPACE when I grep for just the word tablespace, I get: how do i parse this a little better so i have a smaller file to read? This is just an... (4 Replies)
Discussion started by: guessingo
4 Replies

8. Cybersecurity

1000s of undelivered email messages

Hi, My boss has suddenly started receiving 1000s of messages in his inbox. They are undelivered messages that are bouncing back, though the emails weren't coming from him. I guess either these are fake undelivered messages and are just scam emails. Or they are real emails being sent with spoofed... (1 Reply)
Discussion started by: timgolding
1 Replies

9. UNIX Desktop Questions & Answers

How do you [e]grep for multiple values within multiple files?

Hi I'm sure there's a way to do this, but I ran out of caffeine/talent before getting the answer in a long winded alternate way (don't ask ;) ) The task I was trying to do was scan a directory of files and show only files that contained 3 values: I940 5433309 2181 I tried many variations... (4 Replies)
Discussion started by: callumw
4 Replies

10. 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
mcxmap(1)							  USER COMMANDS 							 mcxmap(1)

  NAME
      mcxmap - permute or remap the indices of graphs and matrices.

  SYNOPSIS
      mcxmap -imx fname (input) [-o fname (output)] [-make-map (output map file name)] [-make-mapc (output map file name)] [-make-mapr (output map
      file name)] [-cmul a (coefficient)] [-cshift b (translate)] [-rmul c (coefficient)] [-rshift d (translate)] [-mul e (coefficient)] [-shift f
      (translate)]  [-map  fname  (row/col  map file)] [-rmap fname (row map file)] [-cmap fname (column map file)] [-mapi fname (row/col map file
      (use inverse))] [-rmapi fname (row map file (use inverse))] [-cmapi fname (column map file (use inverse))] [-tab fname (read (and  map)  tab
      file)]

  DESCRIPTION
      This utility relabels graphs or matrices. Its main use is in applying a map file to a given matrix or graph. A map file contains a so called
      map matrix in mcl format that has some special properties (given further below). The functionality of mcxmap can also be provided by mcx, as
      a  mapped  matrix  (i.e.	the  result  of  applying a map matrix to another matrix) is simply the usual matrix product of a matrix and a map
      matrix. However, mcx will construct a new matrix and leave the original matrix to be mapped alone. When dealing with huge matrices,  consid-
      erable  gains  in  efficiency  memory-wise  and  time-wise  can be achieved by doing the mapping in-place.  This is what mcxmap does. In the
      future, its functionality may be embedded in mcx with new mcx operators.

      The special properties of a map matrix are

      o The column domain and row domain are of the same cardinality.
      o Each column has exactly one entry.
      o Each row domain index occurs in exactly one column.

      These properties imply that the matrix can be used as a map from the column domain onto the row domain.  An example map matrix is  found	in
      the EXAMPLES Section.

  OPTIONS
      -o fname (output file)
	Output file.

      -imx fname (input file)
	Input file.

      -map fname (row/col map file))
      -rmap fname (row map file)
      -cmap fname (column map file)
      -mapi fname (row/col map file (use inverse))
      -rmapi fname (row map fil (use inverse))
      -cmapi fname (column map fil (use inverse))
	Different ways to specify map files.

      -make-map (output map file name)
      -make-mapc (output map file name)
      -make-mapr (output map file name)
	Generate a map that maps the specified domain onto the appropriate canonical domain and write the map matrix to file.

      -cmul a (coefficient)
      -cshift b (translate)
	These  options	have  affect if neither a column map file nor column canonification is specified. If any of the first two options is used,
	column indices i are mapped to a*i+b.

      -rmul c (coefficient)
      -rshift d (translate)
	These options have affect if neither a row map file nor row canonification is specified.  If  any  of  the  first  two	options  is  used,
	indices i are mapped to c*i+d.

      -mul e (coefficient)
      -shift f (translate)
	If  a  map  file  is  specified for a given domain, neither a map file nor canonification is specified. If any of the first two options is
	used, the indices i will be mapped to e*i+f.

      -tab fname (read (and map) tab file)
	This option requires the -map option. mcxmap will output the mapped tab definition.

  EXAMPLES
      The matrix below has two canonical domains which are identical.  It denotes a map of the canonical domain onto itself, in which  node  0	is
      relabeled to 8, node 1 is relabeled to 5, et cetera.

      (mclheader
      mcltype matrix
      dimensions 12x12
      )
      (mclmatrix
      begin
      0  8  $
      1  5  $
      2  3  $
      3  2  $
      4  4  $
      5  6  $
      6  7  $
      7  9  $
      8  1  $
      9  10 $
      10 11 $
      11 0  $
      )

  AUTHOR
      Stijn van Dongen.

  SEE ALSO
      mcxio(5), mcx(1), mcxsubs(1), and mclfamily(7) for an overview of all the documentation and the utilities in the mcl family.

  mcxmap 12-068 						      8 Mar 2012							   mcxmap(1)
All times are GMT -4. The time now is 10:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy