ls command help

Dear Friends,

Actually my final goal is to list out all the .txt files inside ../dat/fpgatst/ and show me only the file name inside that with no extension name ..
Example:
if there is file called LVDS.txt. Then it should display me only the file name ,ie, LVDS

Now I am doing a simple shell script like below

#!/usr/bin/ksh -f
 
ch=$1
if [ $# -lt 1 ];then
        echo "USAGE: $0 testname"
        echo "   [Options]"
        echo "    ls : list all available CSV files"
        exit 1
fi

case $ch in
        ls) echo ""
        echo "====Available CSV files===="
        ls ../dat/fpgatst/*.txt
        exit 1
        ;;
esac

It displays

 ../dat/fpgatst/\*.txt: No such file or directory

if I am trying only

ls ../dat/fpgatst/

Then its working properly..But I when I put *.txt at end . it throws me the above error

I tried also

 ls '../dat/fpgatst/*.txt'  

. It displays me

../dat/fpgatst/*.txt: No such file or directory

And one more thing when I remove -f option from my first line of the programme It seems to be working fine .

I cant even guess what is happening ? Please give me some tips on this ..

Regards,
Prady--

I don't use ksh but my guess is that when ls cannot find any *.txt files then the ls command exits with a return value greater than zero and if zsh -f is the same as set -e in bash then the script will silently exit at that point. You can get rid of the ls error output with something like "2>/dev/null".

I think following should be good enough for you.

ls -1 ../dat/fpgatst/*.txt | cut -d"." -f1

Thanks for the reply.......
Sorry it displays empty lines... :frowning:
I think I have to give something like this what I want

ls -1 ../dat/fpgatst/*.txt | cut -f4 -d/ | cut -f1 -d.

I did like below

ls ../dat/fpgatst/*.txt | gawk '{ LF=split($0, files, "/"); gsub(/\.txt/, "", files[LF]); print files[LF] }'

But I dont want to use gawk stuff here..
basename utility or xargs or something different than gawk/awk

My main problem is the statement
#!/usr/bin/ksh -f

When I do like this the ls command is not working in my shell script ..

Why the -f option forcing ls to not work ...