0

I'm trying to merge the second field of the csv with all the id's in the diff file. codes.csv has 2 fields: ID,Description. I keep getting an error on the second cat.

cat: codes.cvs: No such file or directory.

The file does exist and I'm running the script from the same directory as codes.csv.

for i in `cat diff.txt`;
do
 for j in `cat codes.cvs`;
 do
  id = `sed  "$j"`;
  desc = `sed "?=$j"`;
  if [$i == $id]
  then
    echo "$id $desc"
  fi
 done;
done;

Any ideas what I am doing wrong here?

ExceptionLimeCat
  • 6,191
  • 6
  • 44
  • 77

1 Answers1

1

Looks like a simple typo. codes.cvs should be codes.csv as you indicated the name was everywhere else.

for i in `cat diff.txt`;
do
 for j in `cat codes.csv`;
 do
  id=`sed  "$j"`;
  desc=`sed "?=$j"`;
  if [ $i == $id ]
  then
    echo "$id $desc"
  fi
 done;
done;
user000001
  • 32,226
  • 12
  • 81
  • 108
Buggabill
  • 13,726
  • 4
  • 42
  • 47