in reply to Re: How to Execute unix commands like "WC, tail, Gunzip, ZIP" against a file which is read from directory
in thread How to Execute unix commands like "WC, tail, Gunzip, ZIP" against a file which is read from directory

Hi Monks,

Thanks for your valuable suggestion.

i have used the below code and it works for me

can we store the value of unix command in some variable because when we execute the unix command it will either return 0 or 1, i want to store the value

chdir($dir); foreach my $file (@files) { if ($file=~ m/orig/) { my $lcmd = system("gunzip -c $file|tail -1"); }

Output:

123456|345627899292|000108418|

i want to store the value 123456|345627899292|000108418| in variable so that i can use substr to fetch '000108418'

Thanks a lot for the valuable inputs

thanks & regards,
  • Comment on Re^2: How to Execute unix commands like "WC, tail, Gunzip, ZIP" against a file which is read from directory
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: How to Execute unix commands like "WC, tail, Gunzip, ZIP" against a file which is read from directory
by rajsai28 (Novice) on Jun 07, 2013 at 06:16 UTC
    Hi Monks,

    i got the syntax and please check below

    my $result = `gunzip -c $file|tail -1`;

    where i can get the unix command result

      Maybe you want to read about what the "backticks" operator does. Consult perlop about qx or "backticks".

      Also, in your code snippet, the variable $result was given a name that might indicate its use.

        Hi Monks, thanks all for the wonderfull inputs. my apologies if i repeated the question regards,