Wednesday, December 7, 2022

An one liner to print a table for the number given as input in bash

read -rep $'Enter value of j\n' j && for i in $(seq 10);do echo "$i * $j = "$(($i*$j)); done


otherwise the program would be something like


#!/bin/bash
clear
echo "input number :"
read x
echo
for i in 1 2 3 4 5 6 7 8 9 10
do
#t=`expr $x \* $i`
#echo $t
echo $(( x * i))
i=`expr $i + 1`
done

No comments:

Post a Comment