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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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...):
ls -lR | grep "^\.\|^-" | sed s/^\./ \./ | colrm 1 33
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")
Last edited by Dark_Helmet; 06-14-2004 at 05: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
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:
show times using style STYLE: full-iso, long-iso, iso, locale,
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
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.