Question

Need Linux Commands and instructions for the following:

6. Write a script to display numbers from 1 to n, where n is an integer provided by users (if not, default to 10). Hint: use

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:


#!/bin/bash
read -p "Enter number : " n
if test $n -ge 0
then
   n=$n
else
   n=10
fi
for ((a=1; a <= n ; a++))
do
echo $a
done

output:

.l Result $bash -f main.sh 4 10 12 13 14 15 16 17 18 19 20

Add a comment
Know the answer?
Add Answer to:
Need Linux Commands and instructions for the following: 6. Write a script to display numbers from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write the command to set the following permissions on a script file with the following...

    1. Write the command to set the following permissions on a script file with the following name; myscript.sh Owner: full access; read, write and execute Group: read and execute Other: no access 2. Create a new file with the name "myfirstscript.sh". Write a new script that performs the following tasks in sequence; Display the usernames of currently logged in users; sorted from a-z HINT: You will need to filter the output of the whocommand Display a list of usernames who...

  • In some cases, people who are not strong in Linux may need to run specific Linux...

    In some cases, people who are not strong in Linux may need to run specific Linux commands. To make this easier, you can create a menu-driven program that runs these Linux commands. Such a program allows users to execute the commands without having to actually know about how to execute them. For this scenario, create a menu-driven program that has the following options: 1. List users who are logged in (using the who command) 2. List system information (using the...

  • Write a SHELL SCRIPT: Write a simple shell that is similar to what we have discussed...

    Write a SHELL SCRIPT: Write a simple shell that is similar to what we have discussed in class. while (1) {//repeat forever type_prompt();//display prompt on screen read_command (command, parameters);//read input from terminal if (fork() != theta)//parent wait (NULL);//wait for child else{execve (command, parameters, theta);//execute command}} but contains enough code that it actually works so you can test it. For simplicity, you may assume that all commands are in the directory/bin.

  • Using Kali Linux, the Windows Linux Sub-System, or another Debian based Linux distribution, perform the following...

    Using Kali Linux, the Windows Linux Sub-System, or another Debian based Linux distribution, perform the following tasks based on the Linux Fundamentals lecture. For this lab, take screenshots for all major steps completed to illustrate that each task was successfully completed the same method as would be used for other labs). Tasks: 1. Create a new user named Billy Bob using the command linter face 2. Add Billy Bob to the sudoers group 3. Update and upgrade your Linux distribution...

  • (In Linux) 1. Create a file to write to from your script and save it as...

    (In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...

  • please write down the code Thank you. Write a simple shell that is similar to this: while(1 //repeat forever //display prompt on screen type_prompt )i read_command ( command, parameters); // read inp...

    please write down the code Thank you. Write a simple shell that is similar to this: while(1 //repeat forever //display prompt on screen type_prompt )i read_command ( command, parameters); // read input from terminal if ( fork) 0) // parent //wait for child wait NULL elset execve (commamd, parameters, 0 // execute command but contains enough code that it actually works so you can test it. For simplicity, you may assume that all commands are in the directory /bin Write...

  • 3 Programming Question (45 points) 3.1 Instructions You need to write the code by yourself. Your...

    3 Programming Question (45 points) 3.1 Instructions You need to write the code by yourself. Your implementation must use C/C++ and your code must run on the Linux machine general.asu.edu. Please refer to the programming guide (available under the Assignments folder on Blackboard) for using the general.asu.edu server, as well as compiling and running C/C++ code under Linux For this question, you need to provide a Makefile that compiles your program to an executable named a3 that runs on the...

  • LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check...

    LINUX QUESTIONS (dont have to display output, I will be running these commands myself to check the output) Display the command(s) used to do the following: create an empty file called history by using just a redirection operator. Verify and show. Show/verify all results (i.e., all commands and their corresponding outputs). Wait 1 minute or more and then display the command(s) used to do the following: change the timestamp on the history file you just created. Verify/display the change. Show/verify...

  • Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell...

    Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell variables, and .profile script file, echo SHELL, HOME, PATH, MAIL and TERM are predefined shell variables. You can use the value of a shell variable in a shell command putting $ in front of it. For example, to display the value of the HOME directory of the user, specify $HOME in the echo command like echo $HOME. Do not give just the value of...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to input 10 int numbers from the user...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT