Sponsored Content
Top Forums Shell Programming and Scripting Need help for file filteration script...... Post 302599046 by ektubbe on Thursday 16th of February 2012 05:00:07 AM
Old 02-16-2012
Data

Quote:
Originally Posted by ctsgnb
Code:
awk 'NR==FNR{a[$1];next}FNR==1{f=FILENAME "_new"}($1 in a){print $0 > f}' F A B C D E

Your results will be in the files
A_new
B_new
C_new
...

Of course you can specify abolute path.
Code:
awk 'NR==FNR{a[$1];next}FNR==1{f=FILENAME "_new"}($1 in a){print $0 > f}' /home/anubha/ed/F /home/anubha/A /home/anubha/B /home/anubha/C /home/anubha/D /home/anubha/E

The awk code can also easyly be adapted to handle better the naming and the location of the target file i just did a quick shot here.
i use some crap version of linux....which doesnt hv sed/awk plugin installed in it....i dunno bt code doesnt wrk wid sed/awk...cn u suggst wid grep or fgrep... Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies

2. Shell Programming and Scripting

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... :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 Code: ... (0 Replies)
Discussion started by: ektubbe
0 Replies

3. 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

4. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

5. Shell Programming and Scripting

Script to call a menu script and redirect each option to a text file

Hello, I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file. For example;- In the script MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies

6. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

7. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

8. Shell Programming and Scripting

What is the function of the following lines at the top of a shell script file: Directory and Script?

The file starts like this: Directory: <path to the script> Script: <script fife name> #!bin/ksh ##Comments <actual script> What is the use of the first two lines in the script? What if I save the file without them? What will be the effect? They are not comments. Im very new to this,... (4 Replies)
Discussion started by: remytom
4 Replies

9. Shell Programming and Scripting

Shell script (sh file) logic to compare contents of one file with another file and output to file

Shell script logic Hi I have 2 input files like with file 1 content as (file1) "BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt File 2 contents as fle(2) "BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt I want to get... (22 Replies)
Discussion started by: pottic
22 Replies

10. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies
File::HomeDir::Unix(3)					User Contributed Perl Documentation				    File::HomeDir::Unix(3)

NAME
File::HomeDir::Unix - Find your home and other directories on legacy Unix SYNOPSIS
use File::HomeDir; # Find directories for the current user $home = File::HomeDir->my_home; # /home/mylogin $desktop = File::HomeDir->my_desktop; # All of these will... $docs = File::HomeDir->my_documents; # ...default to home... $music = File::HomeDir->my_music; # ...directory $pics = File::HomeDir->my_pictures; # $videos = File::HomeDir->my_videos; # $data = File::HomeDir->my_data; # DESCRIPTION
This module provides implementations for determining common user directories. In normal usage this module will always be used via File::HomeDir. SUPPORT
See the support section the main File::HomeDir module. AUTHORS
Adam Kennedy <adamk@cpan.org> Sean M. Burke <sburke@cpan.org> SEE ALSO
File::HomeDir, File::HomeDir::Win32 (legacy) COPYRIGHT
Copyright 2005 - 2011 Adam Kennedy. Some parts copyright 2000 Sean M. Burke. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.3 2012-10-19 File::HomeDir::Unix(3)
All times are GMT -4. The time now is 11:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy