![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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
Can anyone advise on the best way of doing so? Thank you in advanced. |
|
||||
|
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 and the files to be copied. HTH Chris |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|