To show only file name without the entire directory path To show only file name without the entire directory path unix unix

To show only file name without the entire directory path


ls whateveryouwant | xargs -n 1 basename

Does that work for you?

Otherwise you can (cd /the/directory && ls) (yes, parentheses intended)


No need for Xargs and all , ls is more than enough.

ls -1 *.txt

displays row wise


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 heredone