Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Here is my scenario. I have two files which are having records with each record's 3-25 characters is an identifier. Based on this I need to compare both of them and update the old file with the new file data if their identifiers match. Identifiers start with 01. Please look at the script below. This is giving some error as "argument expected at line 12 which I am not able to understand.

#!/bin/ksh
while read line
  do
    c=`echo $line|grep '^01' `
    if [ $c -ne NULL ];
      then
        var=`echo $line|cut -c 3-25`
    fi
    while read i
      do
        d=`echo $i|grep '^01' `
        if [ $d -ne NULL ];
          then
            var1=`echo $i|cut -c 3-25`
            if [ $var -eq $var1 ];
              then
                $line=$i
            fi
        fi
      done < test_monday
  done < test_sunday

Please help me out thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
869 views
Welcome To Ask or Share your Answers For Others

1 Answer

I think what you need is :

if [ "$d" != NULL ];

Try.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...