rajsai28 has asked for the wisdom of the Perl Monks concerning the following question:
I need to read each file from the archive directory and need to perform some unix commands on those files
some of the unix commands which i need to perform on files are as follows
wc, tail, gunzip and unzip on files
Directory:archive
files:
orig_file_Jun13.dat.gz
Check_Jun13.dat
Check1_Jun13.dat
as i am new to perl scripting, please help me, i am getting error when i runsub zPrivateSub { my $dir = $OUTPUT_DIR; my $pattern = 'Jun'; opendir( DIR, $dir ); my @files = grep( /$pattern/, readdir(DIR) ); closedir(DIR); foreach my $file (@files) { if ($file=~ m/orig/) { print "$file\n"; my $lcmd = system("wc -l Check_Jun13.dat Check1_Jun13.dat"); my $lcmd = system("gunzip -c orig_file_Jun13.dat.gz|tail -1"); } else { print "NO\n"; } } }
this code wc: cannot open Check_Jun13.dat
wc: cannot open Check1_Jun13.dat 0 total
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading file from the directory
by Anonymous Monk on Jun 05, 2013 at 14:04 UTC | |
|
Re: Reading file from the directory
by ww (Archbishop) on Jun 05, 2013 at 14:16 UTC | |
|
Re: Reading file from the directory
by blue_cowdawg (Monsignor) on Jun 05, 2013 at 14:20 UTC |