Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 474  / 1 Year ago, fri, march 17, 2023, 5:04:57

I don't know how many of you have encountered this, but I find it interesting. Maybe also because I do not totally know what the "echo" command can do. If anyone has the interest and nerves to give me a couple of reasons for this I would be most grateful.



Playing is learning and I must ask you to check with your terminal first:
What is the output of the command echo !T in your terminal?



Here is what the terminal shows me as an output:



echo They are 9 in the fellowship
They are 9 in the fellowship


The terminal I am playing with is using the default bash shell, on Ubuntu 12.04.3 LTS. What does "!T" stand for in the "echo" command?


More From » bash

 Answers
2

!T is not related to echo but is replaced by bash before echo can see it.



A ! that is not followed by a white space character or = starts history substitution. That is it gets replaced with the most recent command in the hostory list that starts with what follows the !.



So !T gets replaced with the most recent command you entered that starts with a T.



echo then just outputs that.


[#27000] Saturday, March 18, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
soahan

Total Points: 230
Total Questions: 123
Total Answers: 123

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
;