Lance_P Lance_P - 2 years ago 142
Linux Question

Executing Perl Scripts Within Variables in Bash

Following my professors exact instructions, I am trying to create a variable named EGG that contains 100 'A's by running this command from my Kali VM:

[email protected]:~# EGG='perl -e "print 'A'x100"'

This is my result when attempting to echo the variable:

[email protected]:~# echo $EGG
perl -e "print Ax100"

In my professor's demonstration, his variable contained 100 'A's as is expected.
Any suggestions on how to fix this?

Answer Source

You need to use back ticks in the shell to capture a command's output.

# EGG=`perl -e "print 'A'x100"`
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download