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 9145951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:38:25+00:00 2026-06-17T10:38:25+00:00

I keep getting an error on line 22: [!: command not found My script

  • 0

I keep getting an error on line 22: [!: command not found

My script Asks for a name, phone number, and date of birth and then amends these details to a comma separated value file called “birthday.csv”.

It then Sorts “birthday.csv” by date of birth. The newly sorted file is then displayed and calculates their age.

Can someone take a look at my script and see why this is popping up.

#!/bin/bash

a=0
while [ $a -lt 2 ];
do
    echo Please enter a first name
    read firstName
    echo Please enter last name
    read lastName
    echo Please enter phone number
    read phoneNumber
    echo Please enter date of birth - format dd/mm/yyyy
    read dob
    echo "$firstName,$lastName,$phoneNumber,$dob" >> userBirthdays.csv
    echo If you would like to add another person press 1 or enter 2 to proceed
    read a
done

    INPUT=./userBirthdays.csv
    OLDIFS=$IFS
    IFS=","
    [! -f INPUT] &  while read Name Surname Telephone DOB
    do
                    birthMonth=${DOB:0:2}
                    birthDay=#10${DOB:3:2}
                    birthYear=${DOB:6:4}

                    currentDate=`date +%d/%m/%Y`

                    currentMonth=${currenDate:0:2}
                    currentDay=#10${currentDate:3:2}
                    currentYear=${currentDate:6:4}

                    if [[ "$currentMonth" -lt "$birthMonth" ]] || [[ "$currentMonth" -eq "$birthMonth" && "$((#10$currentDay))" -lt "$((#10$birthDay))" ]]
                    then
                            let Age=currentYear-birthYear-1
                    else
                            let Age=currentYear-birthYear
                    fi

            echo "Name : $Name"
            echo "Surname : $Surname"
            echo "Telephone : $Telephone"
            echo "DOB : $DOB"
            echo "Age : $Age"
            echo "##########################################"
done < $INPUT
IFS=$OLDIFS
    echo $DATE

exit 0;

Thank you in advance

  • 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-17T10:38:27+00:00Added an answer on June 17, 2026 at 10:38 am

    you need a space between between the [ and ! chars, i.e.

    [ ! -f $INPUT ] && while read ....
    #^-^--------^-^---^------------
    

    Note that you almost certainly want two ‘&’ chars, as in my correction.

    Thanks to @GordonDavisson for another ‘$’ 😉

    IHTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add this awk command on my script but keep getting error.
I am keep getting NullPointerException error at line JSONObject json = userFunctions.uploadFileData(guid, photoName); in
I keep getting this error in the $('#savetickets-list') line. I want to dynamically add
I keep getting an expected identifier error at this line in my code =/
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
I keep getting an error saying that @android:style/Widget.Holo.Light.Button.Borderless is not public and so can't
I'm executing mysqldump command from a Java class but I keep getting the error
I'm trying to install a package that uses global-linum-mode and keep getting: error Autoloading
With the following code, I keep getting error C2535 when I compile. It's complaining
I'm trying to code some stuff for a game but I keep getting error

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.