In a bash script I want to do that but it doesn't work
config.txt :
newdir="build/src"
script.sh :
#!/bin/bash
source config.txt
cd $newdir
: No file or folder of this type
I have this with bash +x script.sh
+ source config.txt
++ newdir=$'build/src\r'
+ cd $'build/src\r'
: Aucun fichier de ce type
sourceis a keyword in bash you should use another variable name, e.g.newdir="build/src"thensource config.txtandcd "$newdir".script.shasbash -x script.shand post the output to tell us where it is failing. Just add it to your question (with each line indented by 4-spaces so it formats correctly) and that will tell us exactly what is going on. You still havesource config.txtunchanged - right? And thebuild/srcdirectory is in the current working directory when you run the script right? Theconfig.txtfile is also in that same directory too?\rby the end of your file path is part of a Window's linefeed, you will want to remove it (retype the path by hand). The error appear as an empty filename because\ris the carriage return char which makes the cursor go back to the start of the line, where: No file or folder of this typewill overwrite the file nameEdit->EOL Conversion->Unix (LF)in the menus ; you will probably see that theWindows (CR LF)menu item is grayed since that's your current linefeeds style (or in the status bar at the bottom of the window you can see "Windows (CR LF)" as the third item from the right)