name of current variable in bash pipe

Question:

In powershell $_ is the name of the current variable being passed with pipes. What is the equivalent of this in Bash?

Let’s say I want to do this

Thanks

Answer:

Bash (or any other Unix shell for that matter) has no such thing.

In PowerShell, what is passed through pipes is an object. In bash, this is the output (to stdout) of the command.

The closes thing you can do is use while:


Note that IFS (Input Field Separator) is used, you can therefore also do:

Source:

name of current variable in bash pipe by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply