![]() |
|
#1
|
|||
|
|||
Use ls command without showing permissionsHi, file names get long and it's nice to reduce the left side of ls -l printout. 'man ls' shows me I can:
Code:
Anybody know how? |
|||
|
#2
|
|||
|
|||
Re: Use ls command without showing permissionsI have been enlightened to two methods so far:
ls -latr | awk '{printf("%7s %s %2s %5s %s\\n",\$5,\$6,\$7,\$8,\$9)}'"; and ls -got | cut -b 1,13-128 and I made shell script to use it as 'myls' which works for my pwd: Code:
|
|
#3
|
||||
|
||||
Re: Use ls command without showing permissionsHey Howard,
Here's another way to "reduce the left": (similar to one of your others -- but no sorting/reversing in this snippet) Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#4
|
|||
|
|||
Re: Use ls command without showing permissionslinux tools like awk are so cool...
You know these are available 'standalone' for the msdos console as well. But how to get the first character of $1.... for directory (or file) That's why I've ended up using this so far: Code:
|
|
#5
|
|||
|
|||
Re: Use ls command without showing permissionsQuote:
First of all: If you have a way that works for you: Rejoice. On the other hand, if you want to investigate awk a little more, you could check out awk's printf. It's a lot like printf() for C So, you could try something like: Code:
See? The "%c" for the first field just prints the first character of the field. Adjust the %s field widths to give it the look that you like. Left as an exercise for the student: The first line of my "ls -l" is "total xxxxx", which results in a line with the single character 't' as the first line of the output when I run that awk script. Your assignment: Either 1. Get rid of that line in the awk output or, better 2. Print the line exactly as ls -l gives it to you. Regards, Dave Footnote: What if some of your file names had spaces as part of their names? "I pity the fool..." ---Mr. T Last edited by davekw7x : 09-Nov-2008 at 12:23.
|
|
#6
|
||||
|
||||
Re: Use ls command without showing permissionsQuote:
Code:
As Dave pointed out though, this example (and the previous post) falls short if a filename contains spaces. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! Last edited by TurboPT : 09-Nov-2008 at 19:11.
|
|
#7
|
|||
|
|||
Re: Use ls command without showing permissionsI had left this tab open on my browser to make a point of getting back to it.
yes I have not needed to reboot for a week or so in fact: Code:
(as opposed to the XP box which slows to a crawl after a couple of days) ...anyhow man awk is overwhelming, I see this:vectorsite.net/tsawk.html and am quickly clued to do this: Code:
%10s dave? you must have some big files on there! Last edited by Howard_L : 15-Nov-2008 at 20:26.
|
|
#8
|
|||
|
|||
Re: Use ls command without showing permissionsQuote:
But what if one of your files had the string "total" as part of its name? If you don't want it to print the first line (record) you could make the awk part look like Code:
Regards, Dave |
|
#9
|
|||
|
|||
Re: Use ls command without showing permissionsRight dave, I'd thought about that and thought a $1 != kindof thing might work and find that this does:
Code:
Now I'm looking at those dot directories . hmmm $9 something... |
|
#10
|
|||
|
|||
Re: Use ls command without showing permissionsQuote:
This is where your C programming experience can be useful. Maybe the conditional can be something like Code:
IWFM---YMMV Regards, Dave |
Recent GIDBlog
Not selected for officer school by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hangman and showing correct letters | Krandygrl00 | C++ Forum | 2 | 20-Mar-2006 13:18 |
| Showing Error as Permission Denied | kazim123 | Apache Web Server Forum | 0 | 03-Aug-2005 04:32 |
| Image Not Showing | hemanth.balaji | MS Visual C++ / MFC Forum | 2 | 12-Jun-2005 16:02 |
| Help build the "Member Usergroups, Promotions and Permissions FAQ" | JdS | GIDForums™ | 4 | 01-Feb-2004 00:58 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The