LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what does cd \ do at the command line (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-cd-%5C-do-at-the-command-line-4175595266/)

sigint-ninja 12-12-2016 03:08 AM

what does cd \ do at the command line
 
only noticed now when you type
cd\ or cd \ ....it gives you a
>

what is this function?

tried google didnt show anything about cd\

Turbocapitalist 12-12-2016 03:31 AM

The backslash escapes the following character. If you do it at the end of a line, it tells the interface that things will continue on the next line. In the case of either a script or an interactive shell, you can do that to make what you are doing more readable.

So specifically with "cd" you are giving it "cd" and then telling it to hang on and wait for whatever you are going to type on the next line.

Edit: Here's an example firing up "qemu" over several lines:

Code:

qemu-system-x86_64 -boot c -redir tcp:2227::22 -redir tcp:4777::80 \
        -netdev user,id=network0 -device e1000,netdev=network0 -m 1024m \
        -enable-kvm -cdrom ~/Torrents/CentOS-7-x86_64-DVD-1511/CentOS-7-x86_64-DVD-1511.iso \
        ~/tmp/centos-7-desk.img


Shadow_7 12-12-2016 03:46 AM

The \ is a line continuation character (or escape character). So the > is the prompt to finish the line. Versus / that is a path character.

Code:

$ echo -e " ""\x48""\x45""\x4c""\x4c""\x4f"
is roughly the same as:

Code:

$ echo -e \
> "\x48"\
> "\x45"\
> "\x4c"\
> "\x4c"\
> "\x4f"


Shadow_7 12-12-2016 03:53 AM

Also, using \ before a command tells it to ignore any alias that might be set for the command.

$ \ls

Where just ls is probably aliased to pass parms that uses colors.

Fat_Elvis 12-13-2016 02:42 PM

Oh boy, that's actually a very difficult thing to explain if you don't have experience with how escape characters work.

Were you, by any chance trying to go to the root directory? In which case:

Quote:

cd /
should be what you are looking for.


All times are GMT -5. The time now is 02:31 AM.