How can I make ls and xargs combined omit path
- by Steve McLeod
I have a folder called lib. In that folder are some files. I want to obtain all the names of the files that end in .jar, and concatenate them into a line, separated by spaces. I don't want the path name at all.
I've tried this:
ls lib/*.jar | xargs
and the output is
lib/file1.jar lib/file2.jar
But what I'm trying to get is
file1.jar file2.jar
How can I do this?
I've also tried find but I get the same problem
find lib -name *.jar | xargs