- `\r` - carriage return
- `\n` - newline (line feed)
- `\t` - tab
- `\u{X...}` - a single unicode character, where X... is 1-6 hex digits (0-9, A-F)
## Raw Strings
Raw strings behave the same as a single quoted strings, except that raw strings
may also contain single quotes. This is possible because raw strings are enclosed
by a starting `r#'` and a closing `'#`. This syntax should look familiar to users
of Rust.
```nu
r#'Raw strings can contain 'quoted' text.'#
# => Raw strings can contain 'quoted' text.
```
Additional `#` symbols can be added to the start and end of the raw string to enclose
one less than the same number of `#` symbols next to a `'` symbol in the string. This can
be used to nest raw strings:
```nu
r###'r##'This is an example of a raw string.'##'###
# => r##'This is an example of a raw string.'##
```
## Bare Word Strings
Like other shell languages (but unlike most other programming languages) strings consisting of a single 'word' can also be written without any quotes:
```nu
print hello
# => hello
[hello] | describe
# => list<string>
```
But be careful - if you use a bare word plainly on the command line (that is, not inside a data structure or used as a command parameter) or inside round brackets `(` `)`, it will be interpreted as an external command:
```nu
hello
# => Error: nu::shell::external_command
# =>
# => × External command failed
# => ╭─[entry #5:1:1]
# => 1 │ hello
# => · ──┬──
# => · ╰── executable was not found
# => ╰────
# => help: program not found
```
Also, many bare words have special meaning in nu, and so will not be interpreted as a string:
```nu
true | describe
# => bool
[true] | describe
# => list<bool>
[trueX] | describe
# => list<string>
trueX | describe
# => Error: nu::shell::external_command
# =>
# => × External command failed
# => ╭─[entry #5:1:1]
# => 1 │ trueX | describe
# => · ──┬──
# => · ╰── executable was not found
# => ╰────
# => help: program not found
```
So, while bare strings are useful for informal command line usage, when programming more formally in nu, you should generally use quotes.
## Backtick-quoted Strings
Bare word strings, by their nature, cannot include spaces or quotes. As an alternative, Nushell also includes backtick-quoted
strings using the <code>`</code> character. In most cases, these should operate the same as a bare word string.
For instance, as with a bare word, a backtick-quoted string in the first position of an expression will be interpreted as a _command_ or _path_.
For example:
```nu
# Run the external ls binary found on the path
`ls`
# Move up one directory
`..`
# Change to the "my dir" subdirectory, if it exists
`./my dir`
```
Backtick-quoted strings can be useful for combining globs with files or directories which include spaces:
```nu
ls `./my dir/*`
```
Backtick-quoted strings cannot contain _unmatched_ backticks in the string itself. For example:
`````nu
echo ````
``
echo ```
# Unterminated string which will start a new line in the CLI
`````
## Strings as external commands
You can place the `^` sigil in front of any string (including a variable) to have Nushell execute the string as if it was an external command:
```nu
^'C:\Program Files\exiftool.exe'
let foo = 'C:\Program Files\exiftool.exe'
^$foo
```
You can also use the [`run-external`](/commands/docs/run-external.md) command for this purpose, which provides additional flags and options.
## Appending and Prepending to strings
There are various ways to pre, or append strings. If you want to add something to the beginning of each string closures are a good option:
```nu
['foo', 'bar'] | each {|s| '~/' ++ $s} # ~/foo, ~/bar
['foo', 'bar'] | each {|s| '~/' + $s} # ~/foo, ~/bar
```
You can also use a regex to replace the beginning or end of a string:
```nu
['foo', 'bar'] | str replace -r '^' '~/'# ~/foo, ~/bar
['foo', 'bar'] | str replace -r '$' '~/'# foo~/, bar~/
```
If you want to get one string out of the end then `str join` is your friend: