Search code examples
bashcut

BASH CUT associates with CD


i need some help here as i couldn't figure it out the errors.

read input    
echo -e "$input" | cut -c4-    
cd "$input" | cut -c4-

So I enter cd test, echo output is correct which is test.

I would like to change directory but it gives cd cd test.

Any help is appreciated.


Solution

  • What you want should be:

    cd $(echo -e "$input" | cut -c4-)
    

    Which can be done as well like this (see bash "here strings")

    cd $(cut -c4- <<<$input)