cd ` command meaning and how to exit it?Terminal shows > after entering What mode does the terminal go into when I type a single quote?Unable to enter new commands in terminal — stuck with “>”Using grep with pipe and ampersand to filter errors from findConfigure bash to print exit status of every command enteredHow to remove PATH variable on Ubuntu 14.04?Exit from both root and user with one commandhelp needed understaning ls format meaningHow exit from tty4 terminal without using Alt+SysRq+B to exit?Exit terminal after dd command complete“XXX is hashed” meaning from type command?How does the history command work?Open XFCE Terminal Window and Run command in same Window
Is this state of Earth possible, after humans left for a million years?
How to select certain lines (n, n+4, n+8, n+12...) from the file?
Is ‘despite that’ right?
Renting a house to a graduate student in my department
Can more than one creature benefit from multiple Hunter's Mark spells cast on the same target?
What does formal training in a field mean?
What was the notion of limit that Newton used?
What do "KAL." and "A.S." stand for in this inscription?
Why does the Earth follow an elliptical trajectory rather than a parabolic one?
Can the president of the United States be guilty of insider trading?
What can cause an unfrozen indoor copper drain pipe to crack?
Passport stamps art, can it be done?
When quoting someone, is it proper to change "gotta" to "got to" without modifying the rest of the quote?
What's the difference between const array and static const array in C/C++
Are there variations of the regular runtimes of the Big-O-Notation?
How to handle DM constantly stealing everything from sleeping characters?
How to make a language evolve quickly?
If a character drops a magic item that turns on/off, does that item turn off when they drop it?
Is a vertical stabiliser needed for straight line flight in a glider?
Remove color cast in darktable?
What was the plan for an abort of the Enola Gay's mission to drop the atomic bomb?
Pre-1993 comic in which Wolverine's claws were turned to rubber?
Why do protein solutions have to be alkalised in biuret test?
We are two immediate neighbors who forged our own powers to form concatenated relationship. Who are we?
cd ` command meaning and how to exit it?
Terminal shows > after entering What mode does the terminal go into when I type a single quote?Unable to enter new commands in terminal — stuck with “>”Using grep with pipe and ampersand to filter errors from findConfigure bash to print exit status of every command enteredHow to remove PATH variable on Ubuntu 14.04?Exit from both root and user with one commandhelp needed understaning ls format meaningHow exit from tty4 terminal without using Alt+SysRq+B to exit?Exit terminal after dd command complete“XXX is hashed” meaning from type command?How does the history command work?Open XFCE Terminal Window and Run command in same Window
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
when I type
$ cd `
into a terminal, then I get this
>
even ls
or cd
is not working, please explain the meaning of the above command and how do I exit it?
command-line bash cd-command
New contributor
add a comment |
when I type
$ cd `
into a terminal, then I get this
>
even ls
or cd
is not working, please explain the meaning of the above command and how do I exit it?
command-line bash cd-command
New contributor
2
Ctrl+C or another `. All quotes must be terminated properly. See en.wikipedia.org/wiki/Command_substitution
– FedonKadifeli
May 6 at 20:25
As for the meaning, the single backquote, ` , tells the shell that you are starting a command substitution and>
means that the shell wants you to complete it.
– John1024
May 6 at 20:28
Duplicate on Unix & Linux: What is the effect of a lone backtick at the end of a command line?, related: What mode does the terminal go into when I type a single quote?, Terminal shows > after entering backslash
– wjandrea
May 6 at 21:08
Possible duplicate of Unable to enter new commands in terminal — stuck with “>”
– wjandrea
May 6 at 21:10
add a comment |
when I type
$ cd `
into a terminal, then I get this
>
even ls
or cd
is not working, please explain the meaning of the above command and how do I exit it?
command-line bash cd-command
New contributor
when I type
$ cd `
into a terminal, then I get this
>
even ls
or cd
is not working, please explain the meaning of the above command and how do I exit it?
command-line bash cd-command
command-line bash cd-command
New contributor
New contributor
edited May 7 at 2:36
pomsky
34.4k11108141
34.4k11108141
New contributor
asked May 6 at 20:22
Vaishnava HariVaishnava Hari
62
62
New contributor
New contributor
2
Ctrl+C or another `. All quotes must be terminated properly. See en.wikipedia.org/wiki/Command_substitution
– FedonKadifeli
May 6 at 20:25
As for the meaning, the single backquote, ` , tells the shell that you are starting a command substitution and>
means that the shell wants you to complete it.
– John1024
May 6 at 20:28
Duplicate on Unix & Linux: What is the effect of a lone backtick at the end of a command line?, related: What mode does the terminal go into when I type a single quote?, Terminal shows > after entering backslash
– wjandrea
May 6 at 21:08
Possible duplicate of Unable to enter new commands in terminal — stuck with “>”
– wjandrea
May 6 at 21:10
add a comment |
2
Ctrl+C or another `. All quotes must be terminated properly. See en.wikipedia.org/wiki/Command_substitution
– FedonKadifeli
May 6 at 20:25
As for the meaning, the single backquote, ` , tells the shell that you are starting a command substitution and>
means that the shell wants you to complete it.
– John1024
May 6 at 20:28
Duplicate on Unix & Linux: What is the effect of a lone backtick at the end of a command line?, related: What mode does the terminal go into when I type a single quote?, Terminal shows > after entering backslash
– wjandrea
May 6 at 21:08
Possible duplicate of Unable to enter new commands in terminal — stuck with “>”
– wjandrea
May 6 at 21:10
2
2
Ctrl+C or another `. All quotes must be terminated properly. See en.wikipedia.org/wiki/Command_substitution
– FedonKadifeli
May 6 at 20:25
Ctrl+C or another `. All quotes must be terminated properly. See en.wikipedia.org/wiki/Command_substitution
– FedonKadifeli
May 6 at 20:25
As for the meaning, the single backquote, ` , tells the shell that you are starting a command substitution and
>
means that the shell wants you to complete it.– John1024
May 6 at 20:28
As for the meaning, the single backquote, ` , tells the shell that you are starting a command substitution and
>
means that the shell wants you to complete it.– John1024
May 6 at 20:28
Duplicate on Unix & Linux: What is the effect of a lone backtick at the end of a command line?, related: What mode does the terminal go into when I type a single quote?, Terminal shows > after entering backslash
– wjandrea
May 6 at 21:08
Duplicate on Unix & Linux: What is the effect of a lone backtick at the end of a command line?, related: What mode does the terminal go into when I type a single quote?, Terminal shows > after entering backslash
– wjandrea
May 6 at 21:08
Possible duplicate of Unable to enter new commands in terminal — stuck with “>”
– wjandrea
May 6 at 21:10
Possible duplicate of Unable to enter new commands in terminal — stuck with “>”
– wjandrea
May 6 at 21:10
add a comment |
2 Answers
2
active
oldest
votes
Backticks work in pairs. Bash is waiting for you to provide another backtick to complete the command/expression.
>
is simply a prompt for newline which is determined by the value of PS2
generally defined in .bashrc.
Whenever you hit Enter (if the command/expression is incomplete, i.e. backtick isn't closed), bash expects you to complete the command/expression either in one line or multiple lines. For example, you want to evaluate value of 'a' using expr
. You can do
$ a=`
> expr 1 + 3`
will be interpreted as
$ a=`expr 1 + 3`
So, if you want to run some command either complete the required expression or if there is no command/expression required in between backticks, refrain from using that. Another way is to use Ctrl+C, but that would be a Keyboard Interrupt and will make your command to terminate immediately.
To read more about backticks, read these questions on U&L: Understanding backtick and What does ` (backquote/backtick) mean in commands?
This is a good answer buta=`echo $b`
is in most cases a bad example. You will get the value of$b
, with all sequences of whitespace replaced with single spaces, then each word will be expanded as a glob based on the files of the current directory, and then all trailing newlines will be trimmed, and a single newline will be added in the end. I'd say that 99.9% of the time you'd wanta=$b
, and the resta=$(echo "$b")
if you want a single trailing newline.
– user000001
May 6 at 20:59
Hey @user000001, thank you for your valuable comment. What abouta=`expr 1 + 3`
example? (Formatting in comments sucks!!!)
– Kulfy
May 6 at 21:04
1
Yes, that's much better, though surely someone will come along and complain that since the question is tagged [bash], you'd be usinga=$((b+3))
in real code instead ofexpr
;)
– user000001
May 6 at 21:09
1
@user000001 Replaced. The question is about ``` ` ``` and>
, I don't think such complain would occur ;-).
– Kulfy
May 6 at 21:20
1
Consider the complaint made -- we've got so many people using 1970s-eraexpr
syntax because they're used to seeing it around so they think it's normal/expected/correct, vs standardized-since-the-1990s (and thus not at all a bashism)$(( ... ))
POSIX math syntax.date
is a lot more defensible as an example, since it's legitimately needed when writing code for POSIX shells (or versions of bash that aren't recent 4.x addingprintf '%(...)T'
) today.
– Charles Duffy
May 6 at 21:57
add a comment |
The backticks create an execution environment called command substitution. It is used like this, for example:
echo "The date today is `date`"
Here, the date
command is executed first, and its output replaces the part between the backticks, so in the end you get a string with the current date.
Command substitution may span multiple lines, so when you type:
cd `
and press Enter, bash expects you to complete the command substitution, before executing the cd
command. This can be broken either by closing the backtick and pressing Enter, or by pressing CTRL-c (This will abort the command without anything getting executed).
Note that modern guidelines prefer to avoid the backtick syntax for command substitution, and to use $( )
instead, so the first example would be:
echo "The date today is $(date)"
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Vaishnava Hari is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1141052%2fcd-command-meaning-and-how-to-exit-it%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Backticks work in pairs. Bash is waiting for you to provide another backtick to complete the command/expression.
>
is simply a prompt for newline which is determined by the value of PS2
generally defined in .bashrc.
Whenever you hit Enter (if the command/expression is incomplete, i.e. backtick isn't closed), bash expects you to complete the command/expression either in one line or multiple lines. For example, you want to evaluate value of 'a' using expr
. You can do
$ a=`
> expr 1 + 3`
will be interpreted as
$ a=`expr 1 + 3`
So, if you want to run some command either complete the required expression or if there is no command/expression required in between backticks, refrain from using that. Another way is to use Ctrl+C, but that would be a Keyboard Interrupt and will make your command to terminate immediately.
To read more about backticks, read these questions on U&L: Understanding backtick and What does ` (backquote/backtick) mean in commands?
This is a good answer buta=`echo $b`
is in most cases a bad example. You will get the value of$b
, with all sequences of whitespace replaced with single spaces, then each word will be expanded as a glob based on the files of the current directory, and then all trailing newlines will be trimmed, and a single newline will be added in the end. I'd say that 99.9% of the time you'd wanta=$b
, and the resta=$(echo "$b")
if you want a single trailing newline.
– user000001
May 6 at 20:59
Hey @user000001, thank you for your valuable comment. What abouta=`expr 1 + 3`
example? (Formatting in comments sucks!!!)
– Kulfy
May 6 at 21:04
1
Yes, that's much better, though surely someone will come along and complain that since the question is tagged [bash], you'd be usinga=$((b+3))
in real code instead ofexpr
;)
– user000001
May 6 at 21:09
1
@user000001 Replaced. The question is about ``` ` ``` and>
, I don't think such complain would occur ;-).
– Kulfy
May 6 at 21:20
1
Consider the complaint made -- we've got so many people using 1970s-eraexpr
syntax because they're used to seeing it around so they think it's normal/expected/correct, vs standardized-since-the-1990s (and thus not at all a bashism)$(( ... ))
POSIX math syntax.date
is a lot more defensible as an example, since it's legitimately needed when writing code for POSIX shells (or versions of bash that aren't recent 4.x addingprintf '%(...)T'
) today.
– Charles Duffy
May 6 at 21:57
add a comment |
Backticks work in pairs. Bash is waiting for you to provide another backtick to complete the command/expression.
>
is simply a prompt for newline which is determined by the value of PS2
generally defined in .bashrc.
Whenever you hit Enter (if the command/expression is incomplete, i.e. backtick isn't closed), bash expects you to complete the command/expression either in one line or multiple lines. For example, you want to evaluate value of 'a' using expr
. You can do
$ a=`
> expr 1 + 3`
will be interpreted as
$ a=`expr 1 + 3`
So, if you want to run some command either complete the required expression or if there is no command/expression required in between backticks, refrain from using that. Another way is to use Ctrl+C, but that would be a Keyboard Interrupt and will make your command to terminate immediately.
To read more about backticks, read these questions on U&L: Understanding backtick and What does ` (backquote/backtick) mean in commands?
This is a good answer buta=`echo $b`
is in most cases a bad example. You will get the value of$b
, with all sequences of whitespace replaced with single spaces, then each word will be expanded as a glob based on the files of the current directory, and then all trailing newlines will be trimmed, and a single newline will be added in the end. I'd say that 99.9% of the time you'd wanta=$b
, and the resta=$(echo "$b")
if you want a single trailing newline.
– user000001
May 6 at 20:59
Hey @user000001, thank you for your valuable comment. What abouta=`expr 1 + 3`
example? (Formatting in comments sucks!!!)
– Kulfy
May 6 at 21:04
1
Yes, that's much better, though surely someone will come along and complain that since the question is tagged [bash], you'd be usinga=$((b+3))
in real code instead ofexpr
;)
– user000001
May 6 at 21:09
1
@user000001 Replaced. The question is about ``` ` ``` and>
, I don't think such complain would occur ;-).
– Kulfy
May 6 at 21:20
1
Consider the complaint made -- we've got so many people using 1970s-eraexpr
syntax because they're used to seeing it around so they think it's normal/expected/correct, vs standardized-since-the-1990s (and thus not at all a bashism)$(( ... ))
POSIX math syntax.date
is a lot more defensible as an example, since it's legitimately needed when writing code for POSIX shells (or versions of bash that aren't recent 4.x addingprintf '%(...)T'
) today.
– Charles Duffy
May 6 at 21:57
add a comment |
Backticks work in pairs. Bash is waiting for you to provide another backtick to complete the command/expression.
>
is simply a prompt for newline which is determined by the value of PS2
generally defined in .bashrc.
Whenever you hit Enter (if the command/expression is incomplete, i.e. backtick isn't closed), bash expects you to complete the command/expression either in one line or multiple lines. For example, you want to evaluate value of 'a' using expr
. You can do
$ a=`
> expr 1 + 3`
will be interpreted as
$ a=`expr 1 + 3`
So, if you want to run some command either complete the required expression or if there is no command/expression required in between backticks, refrain from using that. Another way is to use Ctrl+C, but that would be a Keyboard Interrupt and will make your command to terminate immediately.
To read more about backticks, read these questions on U&L: Understanding backtick and What does ` (backquote/backtick) mean in commands?
Backticks work in pairs. Bash is waiting for you to provide another backtick to complete the command/expression.
>
is simply a prompt for newline which is determined by the value of PS2
generally defined in .bashrc.
Whenever you hit Enter (if the command/expression is incomplete, i.e. backtick isn't closed), bash expects you to complete the command/expression either in one line or multiple lines. For example, you want to evaluate value of 'a' using expr
. You can do
$ a=`
> expr 1 + 3`
will be interpreted as
$ a=`expr 1 + 3`
So, if you want to run some command either complete the required expression or if there is no command/expression required in between backticks, refrain from using that. Another way is to use Ctrl+C, but that would be a Keyboard Interrupt and will make your command to terminate immediately.
To read more about backticks, read these questions on U&L: Understanding backtick and What does ` (backquote/backtick) mean in commands?
edited May 6 at 21:19
answered May 6 at 20:29
KulfyKulfy
5,85372248
5,85372248
This is a good answer buta=`echo $b`
is in most cases a bad example. You will get the value of$b
, with all sequences of whitespace replaced with single spaces, then each word will be expanded as a glob based on the files of the current directory, and then all trailing newlines will be trimmed, and a single newline will be added in the end. I'd say that 99.9% of the time you'd wanta=$b
, and the resta=$(echo "$b")
if you want a single trailing newline.
– user000001
May 6 at 20:59
Hey @user000001, thank you for your valuable comment. What abouta=`expr 1 + 3`
example? (Formatting in comments sucks!!!)
– Kulfy
May 6 at 21:04
1
Yes, that's much better, though surely someone will come along and complain that since the question is tagged [bash], you'd be usinga=$((b+3))
in real code instead ofexpr
;)
– user000001
May 6 at 21:09
1
@user000001 Replaced. The question is about ``` ` ``` and>
, I don't think such complain would occur ;-).
– Kulfy
May 6 at 21:20
1
Consider the complaint made -- we've got so many people using 1970s-eraexpr
syntax because they're used to seeing it around so they think it's normal/expected/correct, vs standardized-since-the-1990s (and thus not at all a bashism)$(( ... ))
POSIX math syntax.date
is a lot more defensible as an example, since it's legitimately needed when writing code for POSIX shells (or versions of bash that aren't recent 4.x addingprintf '%(...)T'
) today.
– Charles Duffy
May 6 at 21:57
add a comment |
This is a good answer buta=`echo $b`
is in most cases a bad example. You will get the value of$b
, with all sequences of whitespace replaced with single spaces, then each word will be expanded as a glob based on the files of the current directory, and then all trailing newlines will be trimmed, and a single newline will be added in the end. I'd say that 99.9% of the time you'd wanta=$b
, and the resta=$(echo "$b")
if you want a single trailing newline.
– user000001
May 6 at 20:59
Hey @user000001, thank you for your valuable comment. What abouta=`expr 1 + 3`
example? (Formatting in comments sucks!!!)
– Kulfy
May 6 at 21:04
1
Yes, that's much better, though surely someone will come along and complain that since the question is tagged [bash], you'd be usinga=$((b+3))
in real code instead ofexpr
;)
– user000001
May 6 at 21:09
1
@user000001 Replaced. The question is about ``` ` ``` and>
, I don't think such complain would occur ;-).
– Kulfy
May 6 at 21:20
1
Consider the complaint made -- we've got so many people using 1970s-eraexpr
syntax because they're used to seeing it around so they think it's normal/expected/correct, vs standardized-since-the-1990s (and thus not at all a bashism)$(( ... ))
POSIX math syntax.date
is a lot more defensible as an example, since it's legitimately needed when writing code for POSIX shells (or versions of bash that aren't recent 4.x addingprintf '%(...)T'
) today.
– Charles Duffy
May 6 at 21:57
This is a good answer but
a=`echo $b`
is in most cases a bad example. You will get the value of $b
, with all sequences of whitespace replaced with single spaces, then each word will be expanded as a glob based on the files of the current directory, and then all trailing newlines will be trimmed, and a single newline will be added in the end. I'd say that 99.9% of the time you'd want a=$b
, and the rest a=$(echo "$b")
if you want a single trailing newline.– user000001
May 6 at 20:59
This is a good answer but
a=`echo $b`
is in most cases a bad example. You will get the value of $b
, with all sequences of whitespace replaced with single spaces, then each word will be expanded as a glob based on the files of the current directory, and then all trailing newlines will be trimmed, and a single newline will be added in the end. I'd say that 99.9% of the time you'd want a=$b
, and the rest a=$(echo "$b")
if you want a single trailing newline.– user000001
May 6 at 20:59
Hey @user000001, thank you for your valuable comment. What about
a=`expr 1 + 3`
example? (Formatting in comments sucks!!!)– Kulfy
May 6 at 21:04
Hey @user000001, thank you for your valuable comment. What about
a=`expr 1 + 3`
example? (Formatting in comments sucks!!!)– Kulfy
May 6 at 21:04
1
1
Yes, that's much better, though surely someone will come along and complain that since the question is tagged [bash], you'd be using
a=$((b+3))
in real code instead of expr
;)– user000001
May 6 at 21:09
Yes, that's much better, though surely someone will come along and complain that since the question is tagged [bash], you'd be using
a=$((b+3))
in real code instead of expr
;)– user000001
May 6 at 21:09
1
1
@user000001 Replaced. The question is about ``` ` ``` and
>
, I don't think such complain would occur ;-).– Kulfy
May 6 at 21:20
@user000001 Replaced. The question is about ``` ` ``` and
>
, I don't think such complain would occur ;-).– Kulfy
May 6 at 21:20
1
1
Consider the complaint made -- we've got so many people using 1970s-era
expr
syntax because they're used to seeing it around so they think it's normal/expected/correct, vs standardized-since-the-1990s (and thus not at all a bashism) $(( ... ))
POSIX math syntax. date
is a lot more defensible as an example, since it's legitimately needed when writing code for POSIX shells (or versions of bash that aren't recent 4.x adding printf '%(...)T'
) today.– Charles Duffy
May 6 at 21:57
Consider the complaint made -- we've got so many people using 1970s-era
expr
syntax because they're used to seeing it around so they think it's normal/expected/correct, vs standardized-since-the-1990s (and thus not at all a bashism) $(( ... ))
POSIX math syntax. date
is a lot more defensible as an example, since it's legitimately needed when writing code for POSIX shells (or versions of bash that aren't recent 4.x adding printf '%(...)T'
) today.– Charles Duffy
May 6 at 21:57
add a comment |
The backticks create an execution environment called command substitution. It is used like this, for example:
echo "The date today is `date`"
Here, the date
command is executed first, and its output replaces the part between the backticks, so in the end you get a string with the current date.
Command substitution may span multiple lines, so when you type:
cd `
and press Enter, bash expects you to complete the command substitution, before executing the cd
command. This can be broken either by closing the backtick and pressing Enter, or by pressing CTRL-c (This will abort the command without anything getting executed).
Note that modern guidelines prefer to avoid the backtick syntax for command substitution, and to use $( )
instead, so the first example would be:
echo "The date today is $(date)"
add a comment |
The backticks create an execution environment called command substitution. It is used like this, for example:
echo "The date today is `date`"
Here, the date
command is executed first, and its output replaces the part between the backticks, so in the end you get a string with the current date.
Command substitution may span multiple lines, so when you type:
cd `
and press Enter, bash expects you to complete the command substitution, before executing the cd
command. This can be broken either by closing the backtick and pressing Enter, or by pressing CTRL-c (This will abort the command without anything getting executed).
Note that modern guidelines prefer to avoid the backtick syntax for command substitution, and to use $( )
instead, so the first example would be:
echo "The date today is $(date)"
add a comment |
The backticks create an execution environment called command substitution. It is used like this, for example:
echo "The date today is `date`"
Here, the date
command is executed first, and its output replaces the part between the backticks, so in the end you get a string with the current date.
Command substitution may span multiple lines, so when you type:
cd `
and press Enter, bash expects you to complete the command substitution, before executing the cd
command. This can be broken either by closing the backtick and pressing Enter, or by pressing CTRL-c (This will abort the command without anything getting executed).
Note that modern guidelines prefer to avoid the backtick syntax for command substitution, and to use $( )
instead, so the first example would be:
echo "The date today is $(date)"
The backticks create an execution environment called command substitution. It is used like this, for example:
echo "The date today is `date`"
Here, the date
command is executed first, and its output replaces the part between the backticks, so in the end you get a string with the current date.
Command substitution may span multiple lines, so when you type:
cd `
and press Enter, bash expects you to complete the command substitution, before executing the cd
command. This can be broken either by closing the backtick and pressing Enter, or by pressing CTRL-c (This will abort the command without anything getting executed).
Note that modern guidelines prefer to avoid the backtick syntax for command substitution, and to use $( )
instead, so the first example would be:
echo "The date today is $(date)"
edited May 7 at 1:37
Kevin Bowen
15k155972
15k155972
answered May 6 at 20:31
user000001user000001
5231413
5231413
add a comment |
add a comment |
Vaishnava Hari is a new contributor. Be nice, and check out our Code of Conduct.
Vaishnava Hari is a new contributor. Be nice, and check out our Code of Conduct.
Vaishnava Hari is a new contributor. Be nice, and check out our Code of Conduct.
Vaishnava Hari is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1141052%2fcd-command-meaning-and-how-to-exit-it%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Ctrl+C or another `. All quotes must be terminated properly. See en.wikipedia.org/wiki/Command_substitution
– FedonKadifeli
May 6 at 20:25
As for the meaning, the single backquote, ` , tells the shell that you are starting a command substitution and
>
means that the shell wants you to complete it.– John1024
May 6 at 20:28
Duplicate on Unix & Linux: What is the effect of a lone backtick at the end of a command line?, related: What mode does the terminal go into when I type a single quote?, Terminal shows > after entering backslash
– wjandrea
May 6 at 21:08
Possible duplicate of Unable to enter new commands in terminal — stuck with “>”
– wjandrea
May 6 at 21:10