Perl is excellent language to store command output to variable As I know bash isn’t support that
for example
my $value = qx(ls -ltr);
print $value;
it will print: ( example )
-r-xr-xr-x 1 root root 761 May 30 2014 ASon.conf
-r-xr-xr-x 1 root root 699 May 30 2014 ascpl
drwxr-xr-x 2 root root 4096 Feb 24 13:22 da
drwx------ 2 root root 4096 Feb 25 08:08 vm-root
drwxr-x--- 2 root root 4096 Feb 25 08:10 hspeoot
-rw-r--r-- 1 root root 2451 Feb 25 16:12 gry.txt
-rw-r--r-- 1 root root 3112 Mar 1 09:49 new.xml
-rw-r--r-- 1 root root 44893 Mar 1 12:13 SMports.xml
-rwxr-xr-x 1 root root 101 Mar 2 09:56 test
-rwxr-xr-x 1 root root 461340404 Mar 2 10:20 audin.log
the problem is that I write my code with bash and I want to use the Perl add value in my bash script
so is it possible to combine the following line in my bash script?
my $value = qx(ls -ltr);
in way that when I print the value variable it will print the ls -ltr output
"$value"when you echo it, otherwise the white space will be lost.