0% found this document useful (0 votes)
12 views

Linux

AWK is a programming language useful for text processing tasks like creating reports from files, adding functions to text editors, translating file formats, and performing math operations on numeric files. It has two aspects - as a simple text processing utility and as a programming language for complex text processing. Example AWK programs are provided to convert temperatures between Fahrenheit and Celsius and print even numbers in a series. PERL is a programming language well-suited for manipulating text, system administration tasks, web programming, and customizing program output. It combines features of shells, AWK, SED, and GREP. Example PERL programs calculate a factorial and generate terms of the Fibonacci series. PERL stands for Practical

Uploaded by

Abhishek Tomar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Linux

AWK is a programming language useful for text processing tasks like creating reports from files, adding functions to text editors, translating file formats, and performing math operations on numeric files. It has two aspects - as a simple text processing utility and as a programming language for complex text processing. Example AWK programs are provided to convert temperatures between Fahrenheit and Celsius and print even numbers in a series. PERL is a programming language well-suited for manipulating text, system administration tasks, web programming, and customizing program output. It combines features of shells, AWK, SED, and GREP. Example PERL programs calculate a factorial and generate terms of the Fibonacci series. PERL stands for Practical

Uploaded by

Abhishek Tomar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

AWK PROGRAMMING

The AWK test – processing language is useful for such task as:-

 Tallying information from text files and creating reports from the
result.
 Adding additional functions to the text editors like “Vi”
 Translating files from one format to another
 Creating small databases.
 Perform Mathematical operation on files of numeric data.

AWK has two faces:-


 It is a utility for performing simple text – processing tasks and if is
a programming language for performing complex text –
processing tasks.
 AWK statements comprise a programming language.

AWK Program
1) AWK program to convert temperature.
BEGIN

print “enter temperature in Fahrenheit”;

getline f;

C= (5/9) * (f-32);
print “temperature in”c;

How to run AWK program:-


#awk-f temp_conv (here awk is used for running program)

2) AWK program for series of even numbers.


BEGIN

print “enter the limit of series”;

getline num;

i=1;

for(i=1;i<=num;i++)

if (i%2==0)

print i

How to run AWK program:-


#awk–f series (here awk is used for running program)
PERL PROGRAMMING
PERL is a programming language which excels at handling textual
information. It has been used with good success for system
administration tasks on UNIX systems, World Wide Web CGI
programming, as well as customizing the output from other programs.

Perl was developed by Larry Wall as a programming language to take


the place of shell and awk scripts on a UNIX system.

Objective: - Manipulate huge amount of genome data;

Results:-

PERL (It stands for Practical Extraction and Report Language);

 A programming language written by and for working


programming.
 Practical extraction and report language.
 Mother of all filters.
 Combines the most powerful fall like: Shell,awk,sed,grep.
 Handling files-directories process.

PERL Program
1) # Perl to find factorial of given number.
print “input number for factorial”;
#num = <stdin>;
$fact=1;
for($i=1;$i<$num;$i=$i+1)
{
$fact=$fact*$i;
}
print “factorial of $num is %fact”;

How to run Perl program


#perl fact.pl (perl is command to run perl program
pl is file extension)
2) # Perl program for Fibonacci series.
print “input number of term for Fibonacci series”;
$num=<stdin>;
$a=0;
$b=1;
$i=1;
print “$a$b”;
while($i<=$num)
{
$temp=$b;
$b=$a + $b;
$a=$temp;
print $b;
$i=$i+1;
}
How to run perl program.
#perl fact.pl (perl is command to run perl program
pl is file extension)

You might also like