Match File and Copy File Script (Homework, Closed)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Match File and Copy File Script (Homework, Closed)
# 1  
Old 10-04-2009
Match File and Copy File Script (Homework, Closed)

Can you please help on this?

I am looking for the shell script which does following:-

step 1: It should open the file /u/manish/input/FileIndex.dat and read line by line

step 2: Once first line is read (for ex: File1), we have to find a file, that contains this matching filename in the data directory.

step3: if the matching filename is found in the /u/manish/data directory,
step4: These selected files are to be 'copied' to the /u/manish/output directory.

step5: back to step1, for reading the second and subsequent lines in the /u/manish/input/FileIndex.dat file.


Thank you
# 2  
Old 10-04-2009
Code:
file=/tmp/t1

while read files
do
    if [ -f $files ];then
        echo $files
        # do the copy operation here
    fi    
done < $file

# 3  
Old 10-04-2009
This looks like homework to me.

Code:
Is it really a homework?
If not,
 am sorry about the wrong assumption
 please do show us what you have tried so far
If yes,
 please read the rules, there is a separate sub-section dealing with this.

# 4  
Old 10-04-2009
Hello,

Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".

The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!

In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.

Thank you.

The UNIX and Linux Forums
# 5  
Old 10-04-2009
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Help - match file name and copy to Directory

I am trying to sort the following files from folder Bag to Apple, Cat Food, Dog Food. I can get all of the files I want into a new folder, but not sure of the best approch to get them to their final directory My Files ========== apple.1234.ext apple.1235.ext cat food 101.ext Cat Food... (2 Replies)
Discussion started by: mtschroeder
2 Replies

2. UNIX for Dummies Questions & Answers

Script to copy file small interval file

HI Guys whenever i post a transaction , abcd.in file is stored in the temp and vanishes when the transaction is compleated . the abcd.in file stays for 1 sec in temp is der any solution to capture the abcd.in file to another directory cp -r /tmp/abcd.in /tmp/smith.in when i used the... (1 Reply)
Discussion started by: kalyankalyan
1 Replies

3. Solaris

Adding user with restrictions (Closed Homework)

Hello, I would to create a new user with some restriction: Example "Toto" I am a newer in unix please tell me how to do 1. The user will will have only remote access via FTP ( not telnet, ssh etc ...) 2. The user will not be able to access via FTP to other directory 4) He will access only... (1 Reply)
Discussion started by: fedeboubou
1 Replies

4. Shell Programming and Scripting

Linux unix help (homework, closed)

i have to do this but i am confused, Create a file containing the bash functions which perform the following tasks. Clearly label each function. Print out and turn in this file. 1.Write a function which displays the current date, time, username, and current directory. ... (1 Reply)
Discussion started by: CRAZYLITTLELOU
1 Replies

5. UNIX for Dummies Questions & Answers

3 homework questions (thread closed)

1st) how can i print only directories? 2nd) how can i print files that someone used in the last X days (for example, 5). thanks very much, i need it for homework and teacher teachs us nothing:( (1 Reply)
Discussion started by: SupErioR
1 Replies

6. UNIX for Dummies Questions & Answers

Shell script to search for text in a file and copy file

Compete noob question.... I need a script to search through a directory and find files containing text string abcde1234 for example and then copy that file with that text string to another directory help please :eek: (9 Replies)
Discussion started by: imeadows
9 Replies

7. Shell Programming and Scripting

copy file from script file to remote computer

hi, i want copy one or group of file from a computer to others, but i have some problem that do not allow me to do this. i do this by scp command like this : scp <file name> root@cpName:destinationAddress but the problem is that it do not it automatically. it means when it is connecting to... (4 Replies)
Discussion started by: MShirzadi
4 Replies

8. Shell Programming and Scripting

Script to capture new lines in a file and copy it to new file

Hi All, I have a file that gives me new line/output every 5 minutes. I need to create a script that capture new line/output besides "IN CRON_STATUS", in this case the new output is "begin ------ cron_status.sh - -----------". I want this script to capture the line starting from "begin ------... (0 Replies)
Discussion started by: fara_aris
0 Replies

9. UNIX for Dummies Questions & Answers

file activity (open/closed) file descriptor info using KORN shell scripting

I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Discussion started by: Gary Dunn
3 Replies

10. Shell Programming and Scripting

please help (closed homework thread)

I have these questions for my unix class that I can't figure out because I missed a couple of days. They are for a quiz we took last week so by answering the questions you are not bettering my grade or doing my homework. I just want to understand was the answers. My teacher is really bad at... (1 Reply)
Discussion started by: djeung
1 Replies
Login or Register to Ask a Question