0

What is my linux? I use ubuntu on WINDOWS 10 PRO - windows subsystem for linux.

Context the problem: I have two files. The first file is the name 'paths-linux.sh'. Your content is:

CAMINHO_UM="/mnt/c/Projetos/UU/"
CAMINHO_DOIS="/mnt/c/Projetos/AA/"
CAMINHO_TRES="/mnt/c/BB/"

My second file is parquivo2.sh. Your content is:

. ./paths-linux.sh

echo 'Teste 1'
vida='23'
echo "${CAMINHO_DOIS}$vida"

echo 'Teste 2'
vida='23'
echo $CAMINHO_UM"vida"

echo 'Teste 3'
echo ${CAMINHO_TRES}"vida"

echo ${CAMINHO_TRES}

My output is:

Teste 1
23nt/c/Projetos/AA/
Teste 2
vida/c/Projetos/UU/
Teste 3
vida/c/BB/
/mnt/c/BB/

I would like that my output was:

Teste 1
/mnt/c/Projetos/AA/23
Teste 2
/mnt/c/Projetos/UU/vida
Teste 3
/mnt/c/BB/vida
/mnt/c/BB/

So, what's the problem? How I fix that? I would like use env file type. However that error is not missing when change type the file.

  • 1
    Likely your paths-linux.sh has Windows-style (CRLF) line endings instead of plain LF – steeldriver Oct 17 at 2:44
  • Run dos2unix on all your input files. Now, you see that because of these Windows line endings, each even line is folded at the end of your variable and "vida" is overwriting the same line, starting back from its beginning. – thanasisp Oct 17 at 2:58
  • I spended my all day with this before I ask. I am a beginner in linux. So,Thank you very much people! I install dos2unix and I run. The problem was fixed with this.. – Luiz Oct 17 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.