answersLogoWhite

0

Write a shell script to Print a table of any number?

Updated: 12/9/2022
User Avatar

Surajrana007

Lvl 1
12y ago

Best Answer

Improve

$vi multable.sh

echo "enter the value of n:"

read n

i=1

for((i=1;i<=10;i++))

do

echo " $n * $i = `expr $n \* $i`"

done

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a shell script to Print a table of any number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a shell script to count the number of times is appears in a given text file?

You don't need a shell script to do this; use the 'grep' command with the '-c' option to count the number of occurrences of some pattern.


Write a shell script that counts a number of unique word contained in the alphabetical order line by line?

use python, shell is stupid


Write a shell script to show that user is logged in or not?

You don't need a shell script for that; use either 'whoami' or 'id'


What is a shell script to print Avogadro's number?

#!/bin/sh echo "6.0221415 * 10&sup2;&sup3;" #!/bin/sh echo "6.0221415 * 10 ^ 23"


Write a program in shell script to display odd number from 0 to 100?

seq 1 2 99


What command in a script would print on the screen the first variable past to that script?

Well the question is not particularly specific. I assume that we are talking about shell and in this example I would refer to "bash" shell. #!/bin/bash echo $1 this simple script will print first parameter passed to it.


How do you print a line on screen shell script?

That would depend on what shell you're using. Most seem to have a command similar to "echo x" which will print x to the terminal.


How do you write a shell script which counts the number of lines and words present in a given file?

#!/bin/sh wc -lw "$1"


How do you write a shell script which counts the last 10 lines present in a given file?

You don't need a shell script to do this - just use the 'tail' command.


How do you display the values in shell script?

Use the builtin 'echo' or 'print' command followed by the shell variable name, which will substitute the value when printed/displayed.


Write a shell script that prints a list of every unique word in a file in reverse alphabetical order?

cat FILE | awk 'gsub(/ /,"\n") gsub("\n","\n") {print}' | sort -ur


When might it be necessary or advisable to write a shell script instead of a shell function?

A shell function will do nothing unless it is explicitly called by other code, typically in a shell script. A shell script is a runnable, executable process, which can call other shell scripts and/or functions. The question might be worded backwards - it is necessary to write shell functions for shell scripts when certain logical functionality is required to be performed multiple times. Consider a shell function equivalent to a program subroutine - they operate the same way.