Bash scripts to find out missing lines and common lines between two files

Sometime back I had explained how to find the difference and common lines in two files, Using that giving you 2 simple (very simple) scripts

1. Find out the missing lines between two files

cat diff.sh

#!/bin/bash
if [ $# -eq 0 ];then
        echo "No arguemnts given; Usage : ./diff file2 file1"
        exit 1
fi
echo "Lines exist in $2 and not in $1 are :"
grep -Fxv -f $1 $2

2. Find out the common lines between two files

cat common.sh

#!/bin/bash
if [ $# -eq 0 ];then
        echo "No arguments given; Usage : ./common file1 file2"

        exit 1
fi
echo "Common files in $1 and $2 are :"
awk 'NR==FNR{a[$1]++;next} a[$1] ' $1 $2

Enjoy 🙂

Advertisements

Keyboard copy paste shortcuts in putty commandline

Everyone know how to copy and paste characters in putty terminal using mouse (in case you don’t know, selecting the characters using mouse automatically copies and right click paste it) but less people know that it is possible with keyboard as well. You can use the below command to paste the characters into putty terminal

SHIFT + INS 

Enjoy 🙂

Connect to serial console from Linux command line

The easiest way to connect to a serial console from Linux command line is using the screen command. In my example below, I will show you how to connect to a serial console of a server using the serial to usb cable.

[root@test ~]# screen /dev/ttyUSB0
******************************************
 Connected to *******
******************************************

Enjoy 🙂