Sed/paste/AWK/Perl: Merge or Join two lines

In this post we will see how to merge lines in a given file or standard output.  sed 'N;s/\n/ /' filename paste -d " " – – < filename Related posts: how to join lines in a file in Linux? Linux script/command to display lines ends with .(dot) and ;(semicolon) Linux/Unix shell script to number(…)

Shell scripting: Convert a string from lowercase to uppercase

The linux shell has provided us with many hidden gems. Some of things are string manipulation with out using external commands like SED/AWK. In this post we will see how to convert a string from lower case to upper and upper case to lower by using string manipulation techniques and tr command. String manipulation for lower(…)

AWK substr function explained with examples

We already writtn one excellent string manipulation post for shell. This post is in response to the code which I seen in my office for greping IP address from ifconfig command. The command is.. ifconfig eth0 | grep 'inet addr' | cut -d: -f 2 | awk '{print $1}' Above command explanation: Grep command will filter ifconfig command(…)

Learn Python List with examples

A List is an ordered set of values, where each value is identified by an index. The values that make up a list are called its elements. Lists are similar to strings, which are ordered sets of characters, except that the elements of a list can have any type, you can put numbers, letters, strings(…)

10+ Python Tuples examples

Status: Completed A Tuple is a sequence of immutable elements, It is similar to a list but uses different syntax. With tuples we cannot change elements. This makes programs more predictable. So tuples can be used as values, unlike classes, they never change. Define Tuple: A tuple is immutable: it cannot be changed after created.(…)

Python String examples

Status :  Completed A 'string' is simply a list of characters in order. A character is anything you can type on the keyboard in one keystroke, like a letter, a number, or a backslash. For example, "hello" is a string. It is five characters long h, e, l, l, o. Strings can also have spaces:(…)

Python Integers explained with examples

An integer in Python, also known as a 'numeric literal', is simply a name used for a numeric value. For this reason, these values are commonly called integers even if they are assigned the value of a real number in the form of an integer and a decimal value. Integers are immutable data types, which(…)

Python Boolean Type and None Type examples

What is Boolean ?  Boolean is a data type, having two values usually denoted True and False, intended to represent the truth values of logic. It is named after "George Boole", who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is the primary result of conditional statements,(…)

Python scripts to download video and audio files

Below are some of my scripts which I used to download videos for offline viewing. Script1: One day I come across a motivational blog which I liked it a lot. Below script will download all the podcasts from that site for my offline listening  #!/usr/bin/env python import urllib2 import re import subprocess for i in(…)

Python Variable Types

In previous tutorial we have learned writing "Hello World!" program in python and using print command and operators, Now we are going to learn what is variable and different variable types in python. First of all, What is variable ? In computer programming, a variable is a storage location or memory location and an associated(…)