Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to generate a listing of files & subfolders that includes only the filename, size and date... I figured the easiest way would be similar to this, but I don't know how to remove the other stuff from the output:
Thanks for the help, but what i meant by "only include ..." was that i didn't want stuff like attributes, owner and group name. I *do* still want the names of folders and their sizes. Also, I should mention that I am using the darwin kernel on a Mac (no printf?). I think the solution would involve piping to awk, and I can't quite get it right. Spaces in filenames are also difficult.
Heh ... I thought of posting that, but it would
omit the leading line with the directory name
for the files underlying and I couldn't be bothered
to build an if-statement ;)
And of course the problem of spaces in filenames.
Your approach would only cover two segments.
cut won't work easily, either, since we don't know
for sure that there's no files with a HUGE size ...
Maybe with a ls -lhR ? :)
Originally posted by Tinkster but it would omit the leading line with the directory name for the files underlying [...] And of course the problem of spaces in filenames.
Exactly. Awk would really need an if statement to do this properly. It took me forever looking through its man page to figure out the syntax just to print that out. If anyone can tell me how to include the necessary conditional, I'd appreciate it. For now, back to man pages...
Originally posted by david_ross Try just stripping off the first 35 (I think) characters from each line
I assume you mean piping to colrm... This would work if columns were all the same size, but they aren't. Also, you lose the folder name that preceeds subfolder listings.
The suggestion of ls -lR | awk '{if ( $1 ~ /\./) print $1; else { print $5 " " $8 " " $9}}' seems pretty close. Just need to change the spaces between items to tabs and figure out filenames with spaces. For the spaced filenames part, is there a way to have awk print out the rest of the line... so that in place of $9, you have $9 through the end?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.