![]() |
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 |
| How can i prepare a file by comparing two other files? | manmohanpv | Shell Programming and Scripting | 3 | 02-18-2008 04:58 AM |
| Comparing contents of files | rrs | Shell Programming and Scripting | 3 | 04-03-2007 09:08 PM |
| comparing shadow files with real files | terrym | UNIX for Advanced & Expert Users | 4 | 02-09-2007 02:38 AM |
| Creating file contents using contents of another file | ReV | Shell Programming and Scripting | 21 | 02-24-2006 10:25 AM |
| shell script comparing files in a file | raina_nalin | Shell Programming and Scripting | 4 | 06-21-2005 07:00 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
comparing files to contents of a file
Hi I have a problem trying to run a while statement.
I have files under one directory that i need to compare to a value in filex and update that file with the result files in the directory are DFC1. DFC5. DFC345. DFC344. DFC9. The program i am trying to run will take the number form the filename and compare it to the value in filex it should run through each value in the directory compare it to the value in filex and if greater then replace the value in filex and remove the filename from the directory i.e. compare DFC1. the value 1 to the value in filex = 0 it is greater so replace value in filex with 1 delete DFC1. and do next filename DFC5. same for DFC345. and DFC344 (but this one should fail) any ideas trying this #! /usr/bin/ksh cd /swm/test/apps/creditors/temp pwd var1=$(ls -t DFC*.) echo $var1 #while read var1 #do echo cat $var1 var2=$(echo $var1|cut -d. -f1|cut -c5-) echo $var2 > /swm/test/apps/creditors/temp/valuex if [$var2 -ge var3=$(cat valuex)] then rm $var1 else echo "the current value is greater than the file $var1 thanks for any help |
|
|||||
|
You could store it in a file:
Code:
# Initial value used to compare. val=$(cat /path/to/file.txt) should contain only one line with the number and must exist in the first run in this case. Finally: Code:
echo "-----------" echo "###########" echo "-----------" echo "val=$val" echo $val > /path/to/file ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|