Actually I didnt find any mistake in the previous code logic .
In some commands ,there was missing space in the ending before closing of bracket .If there is no space before the closing bracket in a bash script, such as in a test expression like [ -d /path/to/directory], it will result in a syntax error. Bash expects a space before the closing bracket (]) to properly interpret the condition. Without this space, bash will fail to recognize the correct end of the condition, leading to a syntax error when the script is executed.
836
Actually I didnt find any mistake in the previous code logic .
In some commands ,there was missing space in the ending before closing of bracket .If there is no space before the closing bracket in a bash script, such as in a test expression like [ -d /path/to/directory], it will result in a syntax error. Bash expects a space before the closing bracket (]) to properly interpret the condition. Without this space, bash will fail to recognize the correct end of the condition, leading to a syntax error when the script is executed.