Bash !$ Trick: Insert the Last Argument of the Previous Command | Linux Today

Bash !$ Trick: Insert the Last Argument of the Previous Command

Written By
i
iDoLinux
May 15, 2025

This shortcut allows you to recall and reuse the last argument from the previous command without having to retype it. Especially when dealing with lengthy file paths or complex commands, !$ can save time and reduce the chance of errors. In this guide, we’ll explore how it works, look at examples, and compare it with related tools like $_ and the Alt + . keyboard shortcut.

If you’re just starting to explore shell scripting, it might be useful to first read this beginner-friendly guide to echo in shell scripting.

i

iDoLinux

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.