How do I start an “if” function in shell that requires the user to input between 4-9 parameters The Next CEO of Stack OverflowHow to display the Linux kernel command line parameters given for the current boot?How to exit out of the shell script successfully so that python subprocess think it is successfull exit?change the extension of all files based on user inputDisplay a line in a text file if variable matches a part in the line?Pass command line parameters to a program inside the shell scriptHow to repeat a command n times then exit?Capturing the user input without requiring “Enter”(Shell Scripting) - Modify files with user inputArguments in `bash -c mycommand arg1 arg2`How can I extract a function from bash/zsh with all its shell-related dependencies?

Why do airplanes bank sharply to the right after air-to-air refueling?

Are there any limitations on attacking while grappling?

How to count occurrences of text in a file?

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

Complex fractions

Why don't programming languages automatically manage the synchronous/asynchronous problem?

Should I tutor a student who I know has cheated on their homework?

Interfacing a button to MCU (and PC) with 50m long cable

How did people program for Consoles with multiple CPUs?

Is it ever safe to open a suspicious html file (e.g. email attachment)?

Why do we use the plural of movies in this phrase "We went to the movies last night."?

How to start emacs in "nothing" mode (`fundamental-mode`)

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Return the Closest Prime Number

Does it take more energy to get to Venus or to Mars?

Would a galaxy be visible from outside, but nearby?

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

How do I go from 300 unfinished/half written blog posts, to published posts?

Why has the US not been more assertive in confronting Russia in recent years?

What can we do to stop prior company from asking us questions?

How to solve a differential equation with a term to a power?

Why do professional authors make "consistency" mistakes? And how to avoid them?

Do I need to enable Dev Hub in my PROD Org?

How do we know the LHC results are robust?



How do I start an “if” function in shell that requires the user to input between 4-9 parameters



The Next CEO of Stack OverflowHow to display the Linux kernel command line parameters given for the current boot?How to exit out of the shell script successfully so that python subprocess think it is successfull exit?change the extension of all files based on user inputDisplay a line in a text file if variable matches a part in the line?Pass command line parameters to a program inside the shell scriptHow to repeat a command n times then exit?Capturing the user input without requiring “Enter”(Shell Scripting) - Modify files with user inputArguments in `bash -c mycommand arg1 arg2`How can I extract a function from bash/zsh with all its shell-related dependencies?










0















I needto see if between 4 and 9 arguments were entered at the command line. Then if so display the first and the third and exit with a code equal to the number of arguments on the command line










share|improve this question







New contributor




user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3





    Since this seems semi-arbitrary, have you learned anything about UNIX shells recently that would help you along this path? What have you tried and what were the results?

    – Jeff Schaller
    2 days ago






  • 1





    Some related reading: Positional Parameters, Conditional Constructs, Bash Builtin Commands, Bourne Builtin Commands

    – Jesse_b
    2 days ago















0















I needto see if between 4 and 9 arguments were entered at the command line. Then if so display the first and the third and exit with a code equal to the number of arguments on the command line










share|improve this question







New contributor




user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 3





    Since this seems semi-arbitrary, have you learned anything about UNIX shells recently that would help you along this path? What have you tried and what were the results?

    – Jeff Schaller
    2 days ago






  • 1





    Some related reading: Positional Parameters, Conditional Constructs, Bash Builtin Commands, Bourne Builtin Commands

    – Jesse_b
    2 days ago













0












0








0








I needto see if between 4 and 9 arguments were entered at the command line. Then if so display the first and the third and exit with a code equal to the number of arguments on the command line










share|improve this question







New contributor




user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I needto see if between 4 and 9 arguments were entered at the command line. Then if so display the first and the third and exit with a code equal to the number of arguments on the command line







linux bash






share|improve this question







New contributor




user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









user344036user344036

1




1




New contributor




user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user344036 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 3





    Since this seems semi-arbitrary, have you learned anything about UNIX shells recently that would help you along this path? What have you tried and what were the results?

    – Jeff Schaller
    2 days ago






  • 1





    Some related reading: Positional Parameters, Conditional Constructs, Bash Builtin Commands, Bourne Builtin Commands

    – Jesse_b
    2 days ago












  • 3





    Since this seems semi-arbitrary, have you learned anything about UNIX shells recently that would help you along this path? What have you tried and what were the results?

    – Jeff Schaller
    2 days ago






  • 1





    Some related reading: Positional Parameters, Conditional Constructs, Bash Builtin Commands, Bourne Builtin Commands

    – Jesse_b
    2 days ago







3




3





Since this seems semi-arbitrary, have you learned anything about UNIX shells recently that would help you along this path? What have you tried and what were the results?

– Jeff Schaller
2 days ago





Since this seems semi-arbitrary, have you learned anything about UNIX shells recently that would help you along this path? What have you tried and what were the results?

– Jeff Schaller
2 days ago




1




1





Some related reading: Positional Parameters, Conditional Constructs, Bash Builtin Commands, Bourne Builtin Commands

– Jesse_b
2 days ago





Some related reading: Positional Parameters, Conditional Constructs, Bash Builtin Commands, Bourne Builtin Commands

– Jesse_b
2 days ago










1 Answer
1






active

oldest

votes


















1














This sounds like a homework assignment, so I will give all the bits of the puzzle that you need to solve it.



  1. The number of arguments are kept in the special variable $#.

  2. The third argument is $3.


  3. To see whether a variable $var is between 3 and 19 (inclusively), use



    if [ "$var" -ge 3 ] && [ "$var" -le 19 ]; then ...; fi


    where ... is the action you'd like to take if the statement is
    true.



  4. Explicitly exiting from a script is done with exit. Explicitly returning from a function is done with return. Both of these take an optional exit status.






share|improve this answer

























  • Thank you so much it worked. I was having trouble wrapping my head around getting the range I was trying to do "$# -eq 4-9" , then I was trying to do it similar to your approach but using the -o flag.

    – user344036
    2 days ago






  • 1





    @user344036 If Kusalananda's answer was helpful to you, it's courteous to mark the answer as "Accepted."

    – Jim L.
    yesterday











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






user344036 is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509088%2fhow-do-i-start-an-if-function-in-shell-that-requires-the-user-to-input-between%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














This sounds like a homework assignment, so I will give all the bits of the puzzle that you need to solve it.



  1. The number of arguments are kept in the special variable $#.

  2. The third argument is $3.


  3. To see whether a variable $var is between 3 and 19 (inclusively), use



    if [ "$var" -ge 3 ] && [ "$var" -le 19 ]; then ...; fi


    where ... is the action you'd like to take if the statement is
    true.



  4. Explicitly exiting from a script is done with exit. Explicitly returning from a function is done with return. Both of these take an optional exit status.






share|improve this answer

























  • Thank you so much it worked. I was having trouble wrapping my head around getting the range I was trying to do "$# -eq 4-9" , then I was trying to do it similar to your approach but using the -o flag.

    – user344036
    2 days ago






  • 1





    @user344036 If Kusalananda's answer was helpful to you, it's courteous to mark the answer as "Accepted."

    – Jim L.
    yesterday















1














This sounds like a homework assignment, so I will give all the bits of the puzzle that you need to solve it.



  1. The number of arguments are kept in the special variable $#.

  2. The third argument is $3.


  3. To see whether a variable $var is between 3 and 19 (inclusively), use



    if [ "$var" -ge 3 ] && [ "$var" -le 19 ]; then ...; fi


    where ... is the action you'd like to take if the statement is
    true.



  4. Explicitly exiting from a script is done with exit. Explicitly returning from a function is done with return. Both of these take an optional exit status.






share|improve this answer

























  • Thank you so much it worked. I was having trouble wrapping my head around getting the range I was trying to do "$# -eq 4-9" , then I was trying to do it similar to your approach but using the -o flag.

    – user344036
    2 days ago






  • 1





    @user344036 If Kusalananda's answer was helpful to you, it's courteous to mark the answer as "Accepted."

    – Jim L.
    yesterday













1












1








1







This sounds like a homework assignment, so I will give all the bits of the puzzle that you need to solve it.



  1. The number of arguments are kept in the special variable $#.

  2. The third argument is $3.


  3. To see whether a variable $var is between 3 and 19 (inclusively), use



    if [ "$var" -ge 3 ] && [ "$var" -le 19 ]; then ...; fi


    where ... is the action you'd like to take if the statement is
    true.



  4. Explicitly exiting from a script is done with exit. Explicitly returning from a function is done with return. Both of these take an optional exit status.






share|improve this answer















This sounds like a homework assignment, so I will give all the bits of the puzzle that you need to solve it.



  1. The number of arguments are kept in the special variable $#.

  2. The third argument is $3.


  3. To see whether a variable $var is between 3 and 19 (inclusively), use



    if [ "$var" -ge 3 ] && [ "$var" -le 19 ]; then ...; fi


    where ... is the action you'd like to take if the statement is
    true.



  4. Explicitly exiting from a script is done with exit. Explicitly returning from a function is done with return. Both of these take an optional exit status.







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









KusalanandaKusalananda

138k17258428




138k17258428












  • Thank you so much it worked. I was having trouble wrapping my head around getting the range I was trying to do "$# -eq 4-9" , then I was trying to do it similar to your approach but using the -o flag.

    – user344036
    2 days ago






  • 1





    @user344036 If Kusalananda's answer was helpful to you, it's courteous to mark the answer as "Accepted."

    – Jim L.
    yesterday

















  • Thank you so much it worked. I was having trouble wrapping my head around getting the range I was trying to do "$# -eq 4-9" , then I was trying to do it similar to your approach but using the -o flag.

    – user344036
    2 days ago






  • 1





    @user344036 If Kusalananda's answer was helpful to you, it's courteous to mark the answer as "Accepted."

    – Jim L.
    yesterday
















Thank you so much it worked. I was having trouble wrapping my head around getting the range I was trying to do "$# -eq 4-9" , then I was trying to do it similar to your approach but using the -o flag.

– user344036
2 days ago





Thank you so much it worked. I was having trouble wrapping my head around getting the range I was trying to do "$# -eq 4-9" , then I was trying to do it similar to your approach but using the -o flag.

– user344036
2 days ago




1




1





@user344036 If Kusalananda's answer was helpful to you, it's courteous to mark the answer as "Accepted."

– Jim L.
yesterday





@user344036 If Kusalananda's answer was helpful to you, it's courteous to mark the answer as "Accepted."

– Jim L.
yesterday










user344036 is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















user344036 is a new contributor. Be nice, and check out our Code of Conduct.












user344036 is a new contributor. Be nice, and check out our Code of Conduct.











user344036 is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509088%2fhow-do-i-start-an-if-function-in-shell-that-requires-the-user-to-input-between%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.