Skip to main content

Timeline for What does \ mean in bash and find?

Current License: CC BY-SA 4.0

7 events
when toggle format what by license comment
Apr 19, 2023 at 21:33 comment added Barmar \f and \n have no special meaning in a quoted string, either. But yes, backslash behaves differently inside quotes, it's literal unless it's before something that needs to be escaped.
Apr 19, 2023 at 21:31 comment added simpleuser I generally agree, except that is not true within quotes and therefore is not an absolute statement. echo "\d\z\k" outputs \d\z\k because those characters have no special meaning to bash inside quoted strings, unlike \f (formfeed), \n (newline), and a few others.
Apr 19, 2023 at 17:32 comment added Barmar The point is that all the other uses of backslash make the next character literal. Backslash-newline doesn't result in a literal newline, it results in nothing.
Apr 19, 2023 at 16:49 comment added simpleuser @Barmar Completely agree, but it is probably better for general understanding to note that technically in the case of \ at the end of the line, it is telling bash to remove the special meaning of the newline that follows (i.e. end of a command; process this input), with the effective result that it allows you to continue the command on the next line. That way, input like ls Wideo\ \<newline>ls<newline> makes it clear why the command is interpreted as trying to ls the file Wideo ls (with a space part of the name) since both the space and newline no longer have their bash special meaning.
Apr 19, 2023 at 16:39 history edited simpleuser CC BY-SA 4.0
Remove extraneous space
Apr 19, 2023 at 15:48 comment added Barmar But in the case of newline, it also removes the character. If you do cd Wideo\<newline>ls it will be equivalent to cd Wideols. That's why you have to put a space before the backslash.
Apr 18, 2023 at 23:49 history answered simpleuser CC BY-SA 4.0