Visit Our UNIX and Linux User Community

complex grep command

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting complex grep command
# 1  
Old 11-21-2007
complex grep command

hi all
i have file call "list.log" which contains like this
00300 000024501043846 0
00300 000034531322871 0
00600 000000489100734 0

and so on ..
the file goes like thisSmilieexample first row)
from position 1-5 the lider number(300),position 7-21
id num(000024501043846), position 33 version number(0).
i need to take every row in "list.log" file and to search file or
files which :
the file_name contain the lider number, and in the file i have one or more rows which
contains the id num with the specific version.
example to the first row in the "list.log" file
00300 000024501043846 0
result /usr/tmp1
name of file : file_num_id_00300_emp_56
result /usr/tmp4
name of file : file_num_id_00300_emp_65
the two files are contain this serial number 000024501043846
with version 0.
the file_num_id_00300_emp_56 is a report ,the size of row is 132.
the problem is that the rows are
not with the same data lets says something like this :
report for customer Alex Swed lider 300
id num date version
000024501043846 21/05/2007 0
car_number involv_num prcnt
1234 3 50%
id num date version
0000299999999474 04/06/2007 1
according to the example the number of the files which contain all the data is two.

i want to join the number of the files which the lider,id_num and version are contain in them.(that include even if the file appear twice in the same file)
to the list.log file
or to other file
the final result should be
lider id_num version number_of_appearances

00300 000024501043846 0 2
how shall i do that ?
best regards

Previous Thread | Next Thread
Test Your Knowledge in Computers #570
Difficulty: Medium
The C programming language allows you to pass a parameter to a function by providing its memory address instead of the value stored in it.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Complex Filter using grep, awk or sed

Hi, I'm not very familiar witrh sed or awk and hope the somebody can help me to solve my problem. I need to filter a text report using grep, sed or awk. I would like to cut out text lines with the pattern INFO and if exists the following lines of the pattern DETAILS. I need te keep the lines with... (4 Replies)
Discussion started by: Frankg
4 Replies

2. Shell Programming and Scripting

How to grep for a complex String?

Hi, I have a file hello.log which has the below entry ./logs/mymac/myserver.log:####<Jun 7, 2015 12:56:54 PM EDT> <> <mymac> < ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <1434640> <BEA-0900> <User user1 in security realm... (3 Replies)
Discussion started by: shifahim
3 Replies

3. Shell Programming and Scripting

Complex grep command

Hallo Team, I need your help and its rather urgent. I have a file with thousands of lines. Here is a sample below: Sample1.txt BW235045560121114833444044@ BW235106757121114-574455394@ BW2349514941211141077771352@ (5 Replies)
Discussion started by: kekanap
5 Replies

4. Shell Programming and Scripting

find command with complex logic

I'm looking to write a script that will do a find of directories and delete them if they are older than x days but keep the last x # of folders even if they are older than x days. The usage is for a deployment location, so we want to keep the location clean but retain maybe the last 2 builds that... (5 Replies)
Discussion started by: MaureenT
5 Replies

5. UNIX for Advanced & Expert Users

complex find command

Hi all, I am trying to execute the following command: find 'path' -ls -exec cksum {} \; As you can see this simply finds files from a given path and runs cksum on them. My problem is this, if i have a FIFO in a directory the find tries to execute cksum on it and gets stuck. From the man page i... (9 Replies)
Discussion started by: noam128
9 Replies

6. Shell Programming and Scripting

Complex Email command in unix

Folks, I have two files, i.e. one.txt and two.dat on unix file system. I need to include the contents of one.txt in the body of the email to the sender and attach two.dat in the same email as an attachment using ksh commands, mailx or uuencode etc... I know how to send them seperately but I... (2 Replies)
Discussion started by: calredd
2 Replies

7. Shell Programming and Scripting

Complex find grep or sed command

Haven't worked in bash for ages. did a good bit of shell scripting in regular sh, but have forgotten most of it. I have several thousand php files that now include the following line at the end of the file. There is no LF or CR/LF before it begins, it is just concatenated to the final line of... (3 Replies)
Discussion started by: sjburden
3 Replies

8. Shell Programming and Scripting

complex command substitution

hi, I have to execute this line below from within a shell script; simply backquoting it is not doing the trick; it is mangling up all the options; but when i type it out on a command line, it executes cleanly. Please help me in getting this right; $ vlc -I dummy --sout='#transcode{vcodec=mp4v,... (5 Replies)
Discussion started by: spopuri
5 Replies

9. Answers to Frequently Asked Questions

advanced/complex uses of the find command

Perhaps the number one advanced find question is: How to stop find from descending into subdirectories? find command Performing a non-recursive find in Unix Use -prune with find command on AIX Searching for files over 30 days old in current directory disk space used for files with in a... (0 Replies)
Discussion started by: Perderabo
0 Replies

10. UNIX for Dummies Questions & Answers

parse text or complex grep ?

I have the following file (records from db) and I need to retrieve in another file only two variables and their values. I have a command but works only for one value. grep ^mob: R25-subs.ldi | sed 's/mob: //' | sort | uniq >text_output Can someone please help me? dn:... (4 Replies)
Discussion started by: jacost
4 Replies

Featured Tech Videos