Meruemu Meruemu - 4 months ago 16
Linux Question

What does ./!$ mean in Linux?

A noobie Linux learner here.

I created a python script and

chmod 700 filename.py
, when I was going to using
./filename.py
, my instructor came and use
./!$
to run the file.

What does the
./!$
that actually mean? I couldn't google it out. I'd greatly appreciate for a link of cheatsheet for the similar commend too.

Thanks in advance.

Answer

Suppose I just ran a command python test.py. This was my last command I entered into the shell. However, its argument was test.py.

Remembering that ./ refers to the current working directory, when I type ./!$ I get the following output:

$ ./!$
./test.py
./test.py: line 1: import: command not found
./test.py: line 2: $'\r': command not found
./test.py: line 3: syntax error near unexpected token `('
'/test.py: line 3: `df = pd.DataFrame([

By context clues my last argument was used as the !$.

If I enter several arguments such as python test.py test2.py I get:

$ ./!$
./test2.py
./test2.py: line 1: import: command not found
Unable to initialize device PRN

Confirming my intuition.

Comments