-1
read -r path
wslpath -a $path

I want to save the output of wslpath in a variable so I can later use:

cd $converted_path

to change the directory. How can I realize that ?

alonewolf
  • 1
  • 1
  • Welcome to Stack Overflow. Please remember to search for existing questions that are similar or the same as yours before posting a new one. This particular question has been asked many, many times, and most have been closed as duplicates of this one - [how-do-i-set-a-variable-to-the-output-of-a-command-in-bash](https://stackoverflow.com/questions/4651437/how-do-i-set-a-variable-to-the-output-of-a-command-in-bash) – NotTheDr01ds Aug 05 '21 at 15:19

1 Answers1

-1

The Bash syntax to capture output of a command is as such:

$MY_VAR=$(wslpath -a $path)

You can later use the variable:

cd $MY_VAR
C. Aknesil
  • 186
  • 3