The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
grep'ing a file until a certain message appears pallak7 Shell Programming and Scripting 3 04-23-2009 11:48 AM
Copying specific files from remote m/c to specific folders jhoomsharabi Shell Programming and Scripting 0 06-12-2008 07:31 AM
move output of awk to array amitrajvarma Shell Programming and Scripting 14 12-21-2007 06:12 AM
Compare directories then move similar ones tgibson2 UNIX for Dummies Questions & Answers 2 02-11-2006 07:58 AM
List specific files from directories Filippo Shell Programming and Scripting 4 02-17-2005 03:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-05-2008
JayC89 JayC89 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 50
grep'ing for specific directories, and using the output to move files

Hello, this is probably another really simple tasks for most of you gurus, however I am trying to make a script which takes an input, greps a specific file for that input, prints back to screen the results (which are directory names) and then be able to use the directory names to move files. Something like;

Code:
read -p "Enter Comp ID: " id

grep $id /usr/local/test/service/bin/services.sh | grep DEST_PREFIX | grep -v "#"| awk -F/ '{print $2}' | sort -u > clients

cp /data/new/* /var/tmp/"$clients"/inbound
So basically everything in the /data/new directory will get copied to all the folders the grep results bring back - if that makes sence.

Can anyone advise on the best way of doing so?

Thank you in advanced.
  #2 (permalink)  
Old 12-06-2008
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
Hi,

if i understand you correctly your commands will result in a file
consisting for directory names line by line? If this is so, try:

Code:
while read clients
do
  cp /data/new/* /var/tmp/"$clients"/inbound
done < clients
If my assumption is wrong, please post an example of your clients-file
and the files to be copied.

HTH Chris
Closed Thread

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 11:40 AM.


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