2

My problem is that within this loop, finalfile is formed, but it does not contain anything when both files are present. the echo "go" is also not displayed. How to resolve this problem or rewrite this code?

codeforester
  • 39,467
  • 16
  • 112
  • 140
reader
  • 31
  • 6

1 Answers1

1

The issue is : (see the related post below). Also, you can't pipe to rm. Here is the corrected code:

if [[ -f file1.csv ]] && [[ -f file2.csv ]]; then
  paste file1.csv file2.csv > finalfile.csv
  rm file1.csv file2.csv
else
  echo "don't go"
  exit 1
fi

See also:

Community
  • 1
  • 1
codeforester
  • 39,467
  • 16
  • 112
  • 140