shellrm

Shell script - rm does not remove directory from variable set by external parameter


I would like to run a shell script test_shell.sh to delete a directory defined by a parameter set in another file test_config.txt.

test_config.txt:

var = testdir

test_shell.sh:

#!/bin/bash

vardel=$(grep var test_config.txt | cut -d ' ' -f3)
echo $vardel
rm -rf $var

The variables are set correctly, but the directory is not deleted. No warning is printed. What causes this?


Solution

  • As commented by @Fravadona, this was related to Windows line endings (CR LF) when read on a unix system.