The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find match in two diff file - local srv and remote server amir07 Shell Programming and Scripting 0 03-07-2008 10:23 AM
combining 2 files with more than one match in second file johnes42 Shell Programming and Scripting 5 12-04-2007 06:58 AM
How to match a logical partition to a file garry AIX 1 09-26-2007 10:52 AM
how to search string and number in one file and check in the other file knshree Shell Programming and Scripting 9 08-24-2007 05:29 AM
Posix string to match [[0-999]] Mair55 UNIX for Dummies Questions & Answers 11 10-16-2005 12:07 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-12-2008
Jae Jae is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 24
match string in a file to file in a directory

Hello awk gurus,

I have a text file (st15.txt) containing many station ids.
st15.txt:
033445
234567
012345
222345
.
.
.
And, I want to match each station number to individual files in a directory, and then
I would like to copy that file into a different folder if any station id matches to a file.
For example,
"ls *.DAT" shows all files in the current directory.
Q012345.DAT
Q033445.DAT
Q123456.DAT
Q222345.DAT
X234567.DAT
X345678.DAT
.
.

If you look at "st15.txt", ONLY 4 stations are matching the files in the current directory. Thus,
033445 matches Q033445.DAT
234567 matches X234567.DAT
012345 matches Q012345.DAT
222345 matches Q222345.DAT

So, all these 4 *.DAT files should be copied into a new directory.
I think that awk would be the solution, but I don't know how to attack this problem.
Thanks,

Jae
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0