I please need help as I am struggling to pass the element .sh requirements.
The out put works as it should: camper: /periodic_table$ ./element.sh 1
The element with atomic number 1 is Hydrogen (H). It’s a nonmetal, with a mass of 1.008 amu.
Hydrogen has a melting point of -259.1 celsius and a boiling point of -252.9 celsius.
camper: /periodic_table$ ./element.sh H
The element with atomic number 1 is Hydrogen (H). It’s a nonmetal, with a mass of 1.008 amu.
Hydrogen has a melting point of -259.1 celsius and a boiling point of -252.9 celsius.
camper: /periodic_table$ ./element.sh Hydrogen
The element with atomic number 1 is Hydrogen (H). It’s a nonmetal, with a mass of 1.008 amu.
Hydrogen has a melting point of -259.1 celsius and a boiling point of -252.9 celsius.
camper: /periodic_table$ ./element.sh 2
The element with atomic number 2 is Helium (He). It’s a nonmetal, with a mass of 4.0026 amu.
Helium has a melting point of -272.2 celsius and a boiling point of -269 celsius.
This was me running the tests and it does as it should however I don’t get the check marks.
Blockquote
This is my bash script:
``
#! /bin/bash
PSQL=“psql --username=freecodecamp --dbname=periodic_table --no-align --tuples-only -c”
if [[ $1 ]]
then
if [[ ! $1 =~ +$ ]]
then
ELEMENT=$($PSQL “SELECT atomic_number, atomic_mass, melting_point_celsius, boiling_point_celsius, symbol, name,
type FROM properties JOIN elements USING(atomic_number) JOIN types USING(type_id) WHERE elements.name LIKE ‘$1%’ ORDER BY atomic_number LIMIT 1”)
else
ELEMENT=$($PSQL “SELECT atomic_number, atomic_mass, melting_point_celsius, boiling_point_celsius, symbol, name,
type FROM properties JOIN elements USING(atomic_number) JOIN types USING(type_id) WHERE elements.atomic_number=$1”)
fi
if [[ -z $ELEMENT ]]
then
echo -e “\nI could not find that element in the database.”
else
echo $ELEMENT | while IFS=| read ATOMIC_NUMBER ATOMIC_MASS MPC BPC SY NAME TYPE
do
echo -e “\nThe element with atomic number $ATOMIC_NUMBER is $NAME ($SY). It’s a $TYPE, with a mass of $ATOMIC_MASS amu.
$NAME has a melting point of $MPC celsius and a boiling point of $BPC celsius.”
done
fi
else
echo -e “\nPlease provide an element as an argument.”
fi
``