Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm doing the following command which gives me all the matching entries,but i'd like to see only the filename,not the full path,so i'm doing this..
Code:
[root@accountingdb scripts]# ls --format single-column /var/www/html/CSA20June/B_Berg/*20080620*
/var/www/html/CSA20June/B_Berg/ipB_Berg200806200001.cgi
but i only want the filename(ipB_Berg200806200001.cgi) returned.
IS there some way in ls to throw away the full path, and only list the filename? I went through the man pages, but i could not find anything. I've tried some pipe commands to grep as well, but my grep skills is not nearly good enough it seems.
edit: apparently basename takes only one arg. To workaround that, xargs seems to do fine:
Code:
ls /some/path/*txt | xargs -n1 basename
This works perfectly thanks. I find it a bit strange that one can't do this directly from ls,but i guess as long as there is a way do do it, all is well.
If you actually cd to the folder first and then do ls, you'll get the filename like you want it. But when you pass the path to ls, it displays that path followed by the filename.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.