Friday 24 January 2020

What is the opendir() function in Perl?


opendir  function is used for reading the content of a particular folder.

Method 1:


opendir(DIRHANDLE,"/some director/path") or die "Can't open directory";

Method 2:


opendir DIRHANDLE, '/some diretory/path' or die "Can't open directory";

Read more »

Labels: , , , , , , , ,

Tuesday 21 January 2020

Important Examples of CURL command in UNIX and Linux

CURL is a command-line tool that is used to transfer data from or to a server using different protocols like HTTP, FTP, SMTP, and more. It is a popular tool in Unix and Linux environments that allows users to send and receive data over the internet. In this article, we will explore 10 examples of cURL command in UNIX and Linux with code examples.

Fetching a Web Page

One of the most common uses of cURL is to fetch web pages from the internet. The following command will fetch the web page and print it to the console.

curl https://www.example.com


Read more »

Labels: , ,

Saturday 18 January 2020

The Role of Social Media in Your SEO Strategy

In today's digital age, social media plays a crucial role in driving website traffic and improving search engine optimization (SEO). Social media can help businesses of all sizes increase their online presence, attract new customers, and improve their website's ranking in search engine results pages (SERPs). In this blog post, we'll explore the role of social media in your SEO strategy and provide some tips on how to leverage social media to improve your website's search engine ranking.

Read more »

Labels: ,

Wednesday 15 January 2020

top 10 examples of date command in Linux

The date command in Linux is used to display and set the system date and time. It is a powerful tool that can display the date and time in various formats, set the system date and time, and perform simple date calculations. 

Here are 10 examples of how the date command can be used in Linux:

Display the current date and time:

date Output: Thu Mar 24 13:25:36 EDT 2022

Read more »

Labels: , ,

Sunday 12 January 2020

Top 10 examples of grep command in UNIX and Linux

The grep command is a powerful tool for searching and filtering text files in UNIX and Linux systems. It allows users to search for a specific pattern in a file or a set of files and display the lines that match that pattern. This command is incredibly versatile and can be used for a variety of tasks, including log analysis, system administration, and programming.

In this blog post, we'll explore 10 examples of the grep command in UNIX and Linux, with code examples to illustrate each use case. By the end of this post, you'll have a better understanding of how to use this command and how it can help you in your day-to-day tasks.

Example 1: Basic Search

The most basic use case for the grep command is to search for a specific pattern in a file. To do this, simply enter the following command:

The most basic use case for the grep command is to search for a specific pattern in a file. To do this, simply enter the following command:

grep apple fruits.txt

For example, to search for the word "apple" in the file "fruits.txt", enter the following command:

This will display all lines in the file that contain the word "apple".

Example 2: Case-Insensitive Search

By default, the grep command is case-sensitive, which means that it will only match patterns that are identical in case to the search term. However, you can use the -i option to perform a case-insensitive search. For example:

grep -i apple fruits.txt


This will match lines that contain "apple", "Apple", or "APPLE".

Example 3: Search Multiple Files

You can also use the grep command to search multiple files at once. To do this, simply specify the filenames separated by spaces. For example:

grep apple fruits.txt vegetables.txt


This will search for the word "apple" in both the "fruits.txt" and "vegetables.txt" files.

Example 4: Search All Files in a Directory

To search all files in a directory, you can use the wildcard character "*". For example:

grep apple *


This will search for the word "apple" in all files in the current directory.

Example 5: Inverse Search

By default, the grep command displays all lines that match the search pattern. However, you can use the -v option to display all lines that do not match the pattern. For example:

grep -v apple fruits.txt


This will display all lines in the "fruits.txt" file that do not contain the word "apple".

Example 6: Search for Whole Words Only

By default, the grep command will match any occurrence of the search pattern, even if it's part of a larger word. For example, the search term "the" will match words like "there", "theme", and "other". To search for whole words only, use the -w option. For example:

grep -w the story.txt


This will only match the word "the", and not words that contain it as a substring.

Example 7: Recursive Search

If you want to search for a pattern in all files in a directory and its subdirectories, use the -r option. For example:

grep -r apple /home/user/documents


This will search for the word "apple" in all files in the "documents" directory and its subdirectories.

Example 8: Count Matches

If you just want to know how many times a pattern appears in a file, use the -c option. For example:

grep -c apple fruits.txt


Example 9:  Do not Matches

Search for lines that do not contain the word "example" in a file "file.txt"

grep -v "example" file.txt



Example 10: Exclude Matches in File

Search for a word "example" in all files except those with a ".txt" extension

grep "example" --exclude=*.txt *


Labels: , ,

Thursday 2 January 2020

python ** operator best practices

The Python programming language has a rich set of operators, each with its own set of use cases. One such operator is the ** operator, which is used to perform exponentiation in Python.

The ** operator is a binary operator, which means that it takes two operands. The first operand is the base, and the second operand is the exponent. The operator returns the result of raising the base to the power of the exponent.

Here is an example that demonstrates the use of the ** operator:

#Compute 2 to the power of 3 result = 2 ** 3 print(result) # Output: 8

In this example, the ** operator is used to raise the base 2 to the power of the exponent 3, resulting in a value of 8.

Read more »

Labels: , ,

Wednesday 1 January 2020

What is a continue function in Perl?


Control statement makes iteration to beginning of loops for next iteration.

Method 1:

$t = 0;

while($t < 3) {
   print "Value of var t = $t\n";
} continue {
   $t = $t + 1;
}


Read more »

Labels: , , ,