Script to download the latest linux kernel

Here is a script that will download the latest kernel source kernel.org. THe script works on the current html page of kernel.org and might break if anything is changed in the page of kernel.org.

latest_kernel:

#!/bin/bash latest_kernel () { latest_link=$(grep -A 1 “latest_link” page | tail -1 | cut -d “\”” -f 2 | cut -d “.” -f 2-) prefix=https://www.kernel.org link=$prefix$latest_link for((i=0;i] 17,430 27.8K/s in 0.6s 2013-08-01 22:23:20 (27.8 KB/s) – “page” saved [17430/17430] FINISHED –2013-08-01 22:23:20– Downloaded: 1 files, 17K in 0.6s (27.8 KB/s) downloading from https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.4.tar.xz –2013-08-01 22:23:20– https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.4.tar.xz Resolving www.kernel.org… 149.20.4.69, 198.145.20.140 Connecting to www.kernel.org|149.20.4.69|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 73187712 (70M) [application/x-xz] Saving to: “linux-3.10.4.tar.xz” 100%[===================================================================================>] 73,187,712 97.3K/s in 11m 18s 2013-08-01 22:34:40 (105 KB/s) – “linux-3.10.4.tar.xz” saved [73187712/73187712] Download complete

Thus we can see from the ouput that the latest kernel 3.10.4 has been downloaded. In case the download gets interrupted then the script will retry the download 3 times before quitting with the message of “Download Failed”.

Category: Linux | Comments Off on Script to download the latest linux kernel

Script to download the latest linux kernel

Here is a script that will download the latest kernel source kernel.org. THe script works on the current html page of kernel.org and might break if anything is changed in the page of kernel.org.

latest_kernel:

#!/bin/bash latest_kernel () { latest_link=$(grep -A 1 “latest_link” page | tail -1 | cut -d “\”” -f 2 | cut -d “.” -f 2-) prefix=https://www.kernel.org link=$prefix$latest_link for((i=0;i] 17,430 27.8K/s in 0.6s 2013-08-01 22:23:20 (27.8 KB/s) – “page” saved [17430/17430] FINISHED –2013-08-01 22:23:20– Downloaded: 1 files, 17K in 0.6s (27.8 KB/s) downloading from https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.4.tar.xz –2013-08-01 22:23:20– https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.4.tar.xz Resolving www.kernel.org… 149.20.4.69, 198.145.20.140 Connecting to www.kernel.org|149.20.4.69|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 73187712 (70M) [application/x-xz] Saving to: “linux-3.10.4.tar.xz” 100%[===================================================================================>] 73,187,712 97.3K/s in 11m 18s 2013-08-01 22:34:40 (105 KB/s) – “linux-3.10.4.tar.xz” saved [73187712/73187712] Download complete

Thus we can see from the ouput that the latest kernel 3.10.4 has been downloaded. In case the download gets interrupted then the script will retry the download 3 times before quitting with the message of “Download Failed”.

Category: Linux | Comments Off on Script to download the latest linux kernel

virtual dice on the linux terminal

Here is a script that will act like a dice, a six sided dice, on the terminal.
On running the script, it will display numbers between 1 and 6 randomly, random number of times and at the end settle to one number just as in a usual dice.

dice.sh :

#!/bin/bash roll_dice() { max_dice=$((max_dice-1)) roll=$RANDOM roll=$((roll % max_roll)) roll=$((roll + 1)) n_cols=$(tput cols) col=$((n_cols/2)) for((i=0;i

Category: Linux | Comments Off on virtual dice on the linux terminal

Splitting a pdf file into seperate pdfs in linux

The pdftk tool can be used to split a given pdf document into separate individual pdf pages. The option to be used with pdftk to achieve this is “burst” i.e.

$ pdftk burst”

The pages are created with the names as pg_0001.pdf for first page,pg_0002.pdf for the second page etc. Example : Let us say we have a pdf file named “temp.pdf” with 10 pages.

$ pdftk temp.pdf burst $ ls doc_data.txt pg_0003.pdf pg_0005.pdf pg_0007.pdf pg_0009.pdf temp.pdf pg_0001.pdf pg_0004.pdf pg_0006.pdf pg_0008.pdf pg_0010.pdf

Thus we can see the temp.pdf has been split into 10 pdf files. The file doc_data.txt has the information of the document.

Category: Linux | Comments Off on Splitting a pdf file into seperate pdfs in linux

Splitting a pdf file into seperate pdfs in linux

The pdftk tool can be used to split a given pdf document into separate individual pdf pages. The option to be used with pdftk to achieve this is “burst” i.e.

$ pdftk burst”

The pages are created with the names as pg_0001.pdf for first page,pg_0002.pdf for the second page etc. Example : Let us say we have a pdf file named “temp.pdf” with 10 pages.

$ pdftk temp.pdf burst $ ls doc_data.txt pg_0003.pdf pg_0005.pdf pg_0007.pdf pg_0009.pdf temp.pdf pg_0001.pdf pg_0004.pdf pg_0006.pdf pg_0008.pdf pg_0010.pdf

Thus we can see the temp.pdf has been split into 10 pdf files. The file doc_data.txt has the information of the document.

Category: Linux | Comments Off on Splitting a pdf file into seperate pdfs in linux

Linux script to create colorful 2013 on the terminal

Here is a script with which you can create the number 2013, on your terminal using any character of your choice. The colors of the numbers will change randomly on every run of hte script.

2013.sh:

#!/bin/bash str_dwn() { rows=$1 s_start=$2 char=$4 str_st_row=$3 rows_end=$((str_st_row+rows)) for((i=str_st_row;i

Category: Linux | Comments Off on Linux script to create colorful 2013 on the terminal

colorful Christmas Tree on linux terminal

Here is a version 2 of the Christmas tree creation script. The script will create a colorful Christmas tree on the terminal. The colors of the tree will change on every run.

The script will take as input the character with which the tree has to be drawn, and any two characters that have to be used to decorated the tree.

Christmas_tree:

#!/bin/bash backslash() { b_st_row=$1 b_st_cols=$2 b_char=$3 deco=$5 b_r_end=$((b_st_row + 5 )) for((p=b_st_row;p

Category: Linux | Comments Off on colorful Christmas Tree on linux terminal

script to find the mac address using linux

Here is a simple script we can use to find the mac address of the network card in our systems.
We will use the command ifconfig to find the mac address and in some distribution ifconfig is available only to the root hence we make use of “sudo” before ifconfig.

For wired connection

sudo ifconfig | grep eth[0-9] | awk ‘{ print $NF}’

For wireless connection

sudo ifconfig | grep wlan[0-9] | awk ‘{print $NF}’

Category: Linux | Comments Off on script to find the mac address using linux

Linux Script to generate random numbers in a given range

Generating random numbers is common recruitment in number of scripts. bash by default gives a variable $RANDOM which when accessed gives a random number between 0 and 32767.

$ echo $RANDOM 4945 $ echo $RANDOM 15819

There might be situations where we might need random numbers between a range of smaller numbers or between zero and a smaller number than 32767. Here is a script which can be used to generate random numbers between any range of numbers.

It takes as input the lower limit and the upper limit of the random numbers required and then generates the required number of random numbers with in the range.

random_numbers

#!/bin/bash echo “Enter range of numbers between which random numbers is required ” echo “lower limit=” read lower echo “upper limit=” read upper echo “How many random numbers do you need” read num diff=$((upper-lower)) echo “Random numbers are ” for((i=0;i

Category: Linux | Comments Off on Linux Script to generate random numbers in a given range

Creating a christmas tree on linux terminal

Here is a script that,when executed, will draw a christmas tree using the characters choosen by the user on the linux terminal.

The script will prompt the user to enter the character using which the tree has to be drawn. Then it will prompt the user to enter two characters that will be used to decorate the tree. The last input it will ask for is the character using which the base of the tree has to be drawn.

chritstmas_tree.sh

#!/bin/bash trapi() { cols=`tput cols` start=$((cols/2)) # char=”*” char=”$3″ rows=$1 rows=$((rows+5)) # tput clear for((i=$1;i

Category: Linux | Comments Off on Creating a christmas tree on linux terminal