The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 2,613β€…    Votes:  5β€…
Tags: command-line   bash  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

Title: What does ${_[0]} mean in bash?
ID: /2020/07/05/What-does-____0__-mean-in-bash_
Created: July 5, 2020    Edited:  July 5, 2020
Upload: December 3, 2023    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false

As others have mentioned ${_[0]} is extra typing for ${_} which in turn can be abbreviated into $_ as it is most commonly used.

As mentioned previously it is a variable that contains the last parameter of the last command used. A practical application is like this:

$ ll /etc/lsb-release
-rw-r--r-- 1 root root 105 Feb 20  2019 /etc/lsb-release

$ cat $_

In the first command the last parameter is /etc/lsb-release. In the second command the parameter is $_, which repeats /etc/lsb-release so you don’t have to retype it.

⇧ I need to re-connect HDMI everytime after boot How to fix screen overlap and top left zoom of HD external monitors while using 4k primary Linux Ubuntu 20?  β‡©