Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this command in Perl do?

Tags:

linux

bash

perl

An entire shell command can be executed like a function, returning its output in place. This is done by surrounding the command with parentheses and prefixing a dollar sign:

u$(perl -e 'print "na";')me

Why do we type u + the command then followed by me? Why don't we just do this?

$(perl -e 'print "uname";')

What is the differences and the goal of the first method?

like image 754
Nidal Fikri Avatar asked Feb 07 '26 19:02

Nidal Fikri


2 Answers

The author's just being cute. There's no practical reason to write:

u$(perl -e 'print "na";')me

versus:

$(perl -e 'print "uname";')

They do the same thing. Really, there's no need for Perl at all when it comes down to it. In a real script you'd just write:

uname
like image 125
John Kugelman Avatar answered Feb 09 '26 12:02

John Kugelman


The author want to hide the word 'uname' from a grep search. Your intentions are not good...

like image 25
Joaquín Ferrero Avatar answered Feb 09 '26 11:02

Joaquín Ferrero