Visit Our UNIX and Linux User Community


Need some Help for file filteration and saving the output in other directory using grep....plz ...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need some Help for file filteration and saving the output in other directory using grep....plz ...
# 1  
Old 02-21-2012
Data Need some Help for file filteration and saving the output in other directory using grep....plz ...

Hi all........
Plss do help me.......in a big trouble... SmilieSmilieSmilie
I have 3 directories named as :1. /home/shuchi/source
2./home/shuchi/destination
3./home/shuchi/filter
now the problem is /home/shuchi/source has say 2 files with extension .txt as given below :
A.txt

Code:
Code:
  msisdn             | imsi | name | subscription | product | date | recharge type 09311424354 | 09488439820 | ekta | yes | VAS | 2012-12-07 | IVR 09128734473 | 83974738734 | priya | no | Non VAS | 2011-08-11 | SMS 09376536263 | 63473627632 | shubhra | yes | VAS | 2011-07-07 | WAP 09655423434 | 13312353343 | shubhi | no | non VAS | 2011-05-04 | SMS 09473874383 | 36267267372 | amita | yes | VAS | 2011-04-05 | IVR

B.txt

Code:
Code:
  msisdn             | imsi | name | subscription | product | date | recharge type 09311424354 | 09488439820 | ekta | yes | VAS | 2012-12-07 | IVR 09128734473 | 83974738734 | priya | no | Non VAS | 2011-08-11 | SMS 09376536263 | 63473627632 | shubhra | yes | VAS | 2011-07-07 | WAP 09302117719 | 13312353343 | shubhi | no | non VAS | 2011-05-04 | SMS 08295708671 | 36267267372 | amita | yes | VAS | 2011-04-05 | IVR

/home/shuchi/filter has one file as below :
msisdn
--------------

Code:
09311424354 09128734473 09487736472 09302117719 08295708671
now on the basis of file present in /home/shuchi/filter i need to have 2 subfiles with the same name as A.txt and B.txt in /home/dstst/destination folder as given below :
A.txt

Code:
Code:
  msisdn             | imsi | name | subscription | product | date | recharge type 09311424354 | 09488439820 | ekta | yes | VAS | 2012-12-07 | IVR 09128734473 | 83974738734 | priya | no | Non VAS | 2011-08-11 | SMS:o

B.txt

Code:
Code:
  msisdn             | imsi | name | subscription | product | date | recharge type 09302117719 | 13312353343 | shubhi | no | non VAS | 2011-05-04 | SMS 08295708671 | 36267267372 | amita | yes | VAS | 2011-04-05 | IVR

i have to write a script which will read files present in /home/shuchi/source one by one i.e. A.txt and B.txt and match them with file present in /home/shuchi/filter and on the basis of msisdn and store the result in /home/shuchi/destination directory.I have to use grep or fgrep as some crappy version of unix being used and awk and sed are not supported ............it would be a grttttttttt help...........SmilieSmilieSmilieSmilie

~Priya...........

Last edited by joeyg; 02-21-2012 at 01:13 PM.. Reason: Please wrap CodeTags around sample data and scripts; easier to read

Previous Thread | Next Thread
Test Your Knowledge in Computers #723
Difficulty: Medium
Niklaus Emil Wirth, an Austrian computer scientist, designed several programming languages, including Pascal,
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command is saving output as blank file

Hi, I am working on a script where I am adding adding colors to few of the info in the output. Now , after that is done , I see colour codes in log files which I don't want to see.:mad::mad::mad::mad: So , I tried using sed command in script as below which gives me o/p (new.log) as blank file... (7 Replies)
Discussion started by: Dream4649
7 Replies

2. Shell Programming and Scripting

Saving files with file name as output

Hi, i need help with a file creation of an output program. I've got a program that with #find creates an output for each files in a directory. If i give this command : -o spec$(date -u +%Y%m%dt%H%M) it creates just one file, overwriting all the others since it is the creation date .... (2 Replies)
Discussion started by: Board27
2 Replies

3. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

4. Shell Programming and Scripting

How to grep the desired output and output to a file?

currently I have process from a raw file to this stage ALTER TABLE "EXCEL_ADMIN"."TC_TXN_VOID" ADD CONSTRAINT "PK_TC_TXN_VOID" PRIMARY KEY ("TC_TXN_IID") ALTER TABLE "EXCEL_ADMIN"."TC_TXN_AMT" ADD CONSTRAINT "PK_TC_TXN_AMT" PRIMARY KEY ("TC_TXN_AMT_IID") ALTER TABLE... (10 Replies)
Discussion started by: jediwannabe
10 Replies

5. Shell Programming and Scripting

Plz Help. Compare 2 files field by field and get the output in another file.

Hi Freinds, I have 2 files . one is source.txt and second one is target.txt. I want to keep source.txt as baseline and compare target.txt. please find the data in 2 files and Expected output. Source.txt 1|HYD|NAG|TRA|34.5|1234 2|CHE|ESW|DES|36.5|134 3|BAN|MEH|TRA|33.5|234... (5 Replies)
Discussion started by: i150371485
5 Replies

6. Shell Programming and Scripting

Need some Help for file filteration and saving the output in other directory

Hi all........ Plss do help me.......in a big trouble... :wall::wall::wall: I have 3 directories named as :1. /home/shuchi/source 2./home/shuchi/destination 3./home/shuchi/filter now the problem is /home/shuchi/source has say 2 files with extension .txt as given below : A.txt msisdn ... (5 Replies)
Discussion started by: ektubbe
5 Replies

7. Shell Programming and Scripting

Need help for file filteration script......

Hiii all... Pls help me out wid below prblm : i have 5 files A,B,C,D and E located at /home/anubha I have a file F located at /home/anubha/ed File F has some records which can be matched in A,B,C,D and E and another set of files on the basis of these filteration should be created i.e.... (5 Replies)
Discussion started by: ektubbe
5 Replies

8. Shell Programming and Scripting

saving output from bash into a file

I am ssh to many servers to get some information... however sometimes the server is unreacheable and i am getting an error. I want to save that output to a file but I am not able to do so... I want to be able to save output of bash into a file.. so when I run this command on a script ssh... (5 Replies)
Discussion started by: eponcedeleonc
5 Replies

9. UNIX for Dummies Questions & Answers

saving command output to a variable

Hello, I have a shell script containing a command string in the following format: command1 | command2 | cut -c9-16 The output from this is a record number (using characters 9-16 of the original output string) e.g. ORD-1234 I wish to save this value to a variable for use in later commands... (4 Replies)
Discussion started by: philjo
4 Replies

10. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies

Featured Tech Videos