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 happened by, and thought I would offer this "brute force" method. Someone mentioned not being able to use colrm because it would whack the directory line. Then why not scoot the directory line over like so (not the prettiest command, but...):
Code:
ls -lR | grep "^\.\|^-" | sed s/^\./ \./ | colrm 1 33
<edit>
That sed line has 33 spaces for the replacement
Ugh... and the grep for the dash at the beginning of a line ought to have an 'l' for links or any other file-type designators you would want to include. (like grep "^\.\|^-\|^l")
</edit>
Last edited by Dark_Helmet; 06-14-2004 at 04:27 PM.
Domo:~/Desktop/test domo$ ls -lR | sed "s/^\(\.\|t\)/ \1/" | colrm 1 33
6 26 May 15:40 filename withspace.mp3
4 14 Jun 10:49 fileone.txt
0 14 Jun 10:07 filetwo.txt
0 14 Jun 11:01 folderone
8 14 Jun 10:08 foldertwo
n 10:08 image1.txt
n 10:08 image2.txt
Ok, from the example you had posted earlier, it looked like the column widths were the same until you got to the file sizes. My apologies. If the reason the column widths are messed up is because of tabs, then it might be possible to use sed and replace them with the appropriate number of spaces. I'm afraid that's all I can think of though.
It's been a while since I took part in this one, but the other
day I found a nice feature in awk that reminded me of your
problem :)
I noticed another potential issue with the output of your ls,
and was wondering whether on MacOS X ls also supports
ls --time-style=long-iso ... well, it's just a matter of counting,
really, and that I don't like to get some timestamps as pure
date, and others as date & time ;)
If it does, the following should make for a reasonably
"pretty" solution to your problem:
Originally posted by Tinkster I noticed another potential issue with the output of your ls,
and was wondering whether on MacOS X ls also supports
ls --time-style=long-iso ...
Wow, it's been a while since this thread...
Thanks again, but here is the beginning of the man page for ls:
Code:
NAME
ls -- list directory contents
SYNOPSIS
ls [-ABCFGHLPRTWZabcdfghiklmnopqrstuwx1] [file ...]
Here's the entire manpage...
--time-style=STYLE
show times using style STYLE: full-iso, long-iso, iso, locale,
+FORMAT
FORMAT is interpreted like `date'; if FORMAT is FORMAT1<new-
line>FORMAT2, FORMAT1 applies to non-recent files and FORMAT2 to
recent files; if STYLE is prefixed with `posix-', STYLE takes
effect only outside the POSIX locale
Oh well ... but what did you think of the change to the
awk bit? :) Now your files could have any number of
spaces ;)
The awk string works tremendously, thank you. I actually ended up writing an Applescript to do what I was originally trying to do. It works on both System 9 and OS X. Running a unix command with your awk string runs way faster however, and I'm defintetly going to use your version for OS X.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.