Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:23:50+00:00 2026-06-01T17:23:50+00:00

This is really simple but since i m still a newbiw in shell scripting,

  • 0

This is really simple but since i m still a newbiw in shell scripting, i not able to do this. It is simple, i have a menu driven script in which when the user enters his choice i loop in the case function and execute the selected menu. Uptil now i was writing the entire code in the same script. Now i am putting the code in each menu option in a external script and accessing the code from there. So it is something like this,

#!/bin/bash
. course_func
file=names.dat
[ ! -f $file ] && > $file
while true
do
clear
echo ------------------------------------------
echo 1. Create a record
echo 2. View Records
echo 3. Search for records
echo 4. Delete records that match a pattern
echo ------------------------------------------
echo "Please enter your choice or enter (q) to quit: \c ";read choice
case $choice in
    1)
    create()
    echo Enter to continue; read junk
    ;;
        *)
    clear
    echo Wat nonsense enter properly
    echo Enter to continue: ;read crap
    ;;
esac
done

Then i created another external script where I wrote the create() function

Code is in the link,

create()
{
  while true
  do
        echo Please enter the name: ;read name
        echo Please enter your surname: ;read surname
        echo Please enter the address: ;read add
        echo Please enter the cell no.: ;read cell
        if yesno Do you really wish to save the following data to file
        then
        echo $name:$surname:$add:$cell >> $file
        clear
        echo The record has been inserted :D
        else 
        echo The record was not save
        fi
        if yesno Do you wish to enter another record
        then
        :
        else
        xit
        fi
  done
}

addRecord()
{

}

search()
{

}

delRecord()
{

}

But i am getting an error,

course_func: line 31: syntax error near unexpected token `}'
course_func: line 31: `}'
menu_driven: line 18: syntax error near unexpected token `echo'
menu_driven: line 18: ` echo Enter to continue; read junk'

Line 31 is where I am ending the addRecord function, which is empty function, for the remaining cases. Can we not have a empty function in bash?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:23:51+00:00Added an answer on June 1, 2026 at 5:23 pm

    Functions may not be empty!

    —Advanced Bash-Scripting Guide: Chapter 24. Functions

    Instead, try:

    addRecord()
    {
        return
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this probably really simple but Im not sure what im doing wrong...
I feel like this might be really simple but I'm just not getting it
I know this is really simple but I cant find the docs for this
This is probably something really simple but I cant see what! Any images I
I know this is a really simple question but my google-fu is failing me.
I just cannot figure this out, it looks really simple but I'm relatively new
This is probably a really simple question but one I've never quite worked out
I'm sure this is really simple, but I can't for the life of me
I'm sure this is really simple, but I can't seem to get it working.
I'm sure this is really simple and I'm drawing a giant blank, but how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.