List files in the current directory - BOURNE SHELL

i am trying to write a program, that will list .txt files and .png files.
it will ask the user what type of files do they want to list! so if the user inputs txt files.. how would you list all the .txt files in the current directory (the directory the program is running)!!

thanks

Welcome to the forum.

You can do something like..

echo -n 'enter your pattern: '
read p
ls *${p}

Execution:

$ bash myscript.sh
enter your pattern: txt 
100.txt          250.txt          checklength.txt  create2.txt      infile.txt       op.txt           str.txt          test2.txt
150.txt          arop.txt     create.txt       day.txt          item.txt         outfile.txt      test.txt         testing.txt
$