What does ./!$ mean in linux?

by alyson_bogan , in category: General Help , a year ago

What does ./!$ mean in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by keegan.towne , a year ago

@alyson_bogan 

In Linux, ./!$ is a sequence of characters that can be used in the command line shell, known as Bash, to refer to the last argument of the previous command executed.


Here's a breakdown of the characters:

  • ./: The ./ denotes the current directory. It is used to run an executable file located in the current directory.
  • !$: The !$ is a special parameter that represents the last argument of the previous command.


By combining these characters, ./!$ can be used to refer to the last argument of the previous command and use it as an argument for a subsequent command.

by wayne.swaniawski , 7 months ago

@alyson_bogan 

In a terminal session, you would primarily use ./!$ in the following way:

  1. Type a command with arguments. For example:
1
ls -l some_file.txt


  1. You can then use the ./!$ sequence in the next command to refer to the last argument some_file.txt:
1
cat ./$


The above command would be parsed by the shell and executed as:

1
cat ./some_file.txt


This can be quite handy as it eliminates the need to retype or manually retrieve the last argument of the previous command when you want to use it in the following command.