Explain what the following statements do:
ls mydir > foo.txtls mydir > foo.txt 2>&1cat file1 file2 > file3cat file1 file2 >> file3
Explain what the following statements do:
ls mydir > foo.txtls mydir > foo.txt 2>&1cat file1 file2 > file3cat file1 file2 >> file3Write the Bash statements to:
banana-file-names.txt with the concatenated contents of every file in the current directory that starts with "banana"banana-file-content.txt with the concatenated contents of every file in the current directory that contains the word "banana"Write the Bash statements to:
Explain what each of the following Bash statements does and the overall result:
$ (date ; ps -ef | awk ‘{print $1}’ | sort | uniq | wc -l ) >> processes.log
Explain what the following Bash command does:
find . -type f -atime -7 > /tmp/recent_files
Explain what the following code does:
package Person;
sub new {
my $self = {
_firstName => undef,
_lastName => undef,
_ssn => undef,
_address => undef,
_salary => undef,
_dept => undef
};
bless $self, 'Person';
return $self;
}
sub print {
my ($self) = @_;
printf( "Name:%s %s\n\n", $self->firstName, $self->lastName );
}
Describe two ways to concatenate strings in Perl. Contrast and compare.
Describe what the following Perl code does:
#!/usr/bin/perl
$numArgs = $#ARGV + 1;
print "$numArgs\n";
foreach $argnum (0 .. $#ARGV) {
print "$ARGV[$argnum]\n";
}
Write code to print the contents of the following array in Perl:
@fruit = ('banana', 'orange', 'apple');
In Perl, how would you allow functions to have private variables that retain their values from call to call?
What is a good way to fetch the contents of a web page in Perl, given a URL?
What is a common way of sending email from a Perl program?