To show only file name without the entire directory path
No need for Xargs and all , ls is more than enough.
ls -1 *.txt
displays row wise
ls whateveryouwant | xargs -n 1 basename
Does that work for you?
Otherwise you can (cd /the/directory && ls)
(yes, parentheses intended)
There are several ways you can achieve this. One would be something like:
for filepath in /path/to/dir/*
do
filename=$(basename $filepath)
... whatever you want to do with the file here
done