1

I get a string from a command that lokos like the following:

part1=$(pip install numpy 2>&1)

part1 has stored some variable like: c:\programdata\anaconda3\lib\site-package

Now I want to append "numpy" to it. To do so I tried it with:

part1+=/numpy

and every other solution listed here: How to concatenate strings in bash

However the output looks like this: 'c:\programdata\anaconda3\lib\site-packages'$'\r''/numpy'

What do I have to do to get rid of this effect?

I am using Windows10 and scripting .sh files.

Kev1n91
  • 3,302
  • 8
  • 41
  • 85

1 Answers1

1

You can use:

part1="${part1/$'\r'}/numpy"

Here "${part1/$'\r'} replaces \r by an empty string. $'\r' is special bash construct to enter escape sequences.

anubhava
  • 713,503
  • 59
  • 514
  • 593