![]() |
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 |
| Need Script to check file exist and compare | rbknisely | UNIX for Dummies Questions & Answers | 1 | 01-16-2008 01:08 AM |
| How to compare two flat files and get changed data | jtshashidhar | Shell Programming and Scripting | 3 | 01-29-2006 10:26 PM |
| How to compare data in two flat files and update them? | rajus19 | Shell Programming and Scripting | 3 | 11-08-2005 11:13 AM |
| Compare Data in the same file | lweegp | UNIX for Dummies Questions & Answers | 1 | 10-17-2005 02:32 AM |
| Compare data files | ithomp | Shell Programming and Scripting | 1 | 06-15-2004 10:08 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi there,
I have written a script called "compare" (see below) to make comparison between 2 files namely test_put.log and Output_A0.log #!/bin/ksh while read file do found="no" while read line do echo $line | grep $file > /dev/null if [ $? -eq 0 ] then echo $file found found="yes" break fi done < test_put.log if [ $found = "no" ] then echo $file not found fi done < Output_A0.log I have managed to extract the output as follows: root@mapserv12 #./compare A0567 found A0678 found A0789 found Can someone give me some clues on how can I delete the files which are found? I really welcome ideas n suggestions. U may even change/ edit my script. Really need some guidance on this. Many Thanks. Lweegp |
|
||||
|
I am not sure my understanding of your requirement is correct. If you simply wants to delete the files that are found then just use rm command. I still not sure whether it solves your requirement or not.
#!/bin/ksh while read file do found="no" while read line do echo $line | grep $file > /dev/null if [ $? -eq 0 ] then echo $file found found="yes" rm $file break fi done < test_put.log if [ $found = "no" ] then echo $file not found fi done < Output_A0.log Cheers Narayana Gupta |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|