Skip to content
Advertisement

Linux shell script, differences between two directories

I made this code

JavaScript

I want to compare two folders and the folder are arguments to the command line.. it should be something like this : ./script.sh dir1 dir2

But i have this eror :

**./director.sh: line 29: `$1′: not a valid identifier **

I want to count the file from dir1 who is argument to the command line.

Can someone help me please ?

Advertisement

Answer

This is the main error:

JavaScript
  1. $1 is not a valid variable name
  2. don’t parse ls

Do this instead

JavaScript

Also, quote your variables: you want to protect your script from any filenames containing whitespace.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement