Apple
Simplify Terminal Directory Listings
06/09/2009 11:13
First of all, I have to give credit for this entry to
Rob Griffiths from Macworld. It was he who was
responsible for getting me to write this blog entry.
Today’s 10-up Tweet featured a simple improvement to the ls -al command. This command lists all files in long format, and the output is quite verbose:
$ ls -l
total 0
drwx------@ 4 Steve staff 136 Jun 9 17:38 Desktop
drwxr-xr-x@ 222 Steve staff 7548 Jun 9 17:45 Documents
drwx------@ 4 Steve staff 136 Jun 9 07:43 Downloads
drwx------@ 51 Steve staff 1734 Jun 9 09:04 Library
drwx------@ 8 Steve staff 272 May 14 19:04 Movies
drwx------@ 5 Steve staff 170 Apr 30 06:58 Music
drwx------@ 9 Steve staff 306 May 16 20:38 Pictures
drwxr-xr-x@ 6 Steve staff 204 May 29 17:31 Public
drwxr-xr-x@ 4 Steve staff 136 Jun 7 18:06 Sites
drwx------ 3 Steve staff 102 May 20 03:06 StuffIt
etc...
But if you’ve got files with lengthy names, this output can get quite wide—and the thing you may be most interested in, the filename, will be a good distance off to the right. The command line suggestion is to use ls -hog instead. This “piggie” version of ls uses three modifiers to simplify the output. The h modifier converts file sizes to human-readable form (7.4K instead of 7548). The next two options work together to eliminate both the owner (Steve) and the group (staff) from the output. When you use this version of the command, the output is much cleaner:
$ ls -hog
total 0
drwx------@ 4 136B Jun 9 17:38 Desktop
drwxr-xr-x@ 222 7.4K Jun 9 17:45 Documents
drwx------@ 4 136B Jun 9 07:43 Downloads
drwx------@ 51 1.7K Jun 9 09:04 Library
drwx------@ 8 272B May 14 19:04 Movies
drwx------@ 5 170B Apr 30 06:58 Music
drwx------@ 9 306B May 16 20:38 Pictures
drwxr-xr-x@ 6 204B May 29 17:31 Public
drwxr-xr-x@ 4 136B Jun 7 18:06 Sites
drwx------ 3 102B May 20 03:06 StuffIt
etc...
Now there’s only a bit of added information at the front—the permissions on the file, and the number of hard links (ln) to that file. If you’d rather not see those columns, you can send the output of ls to the cut command, which can trim columns from the output prior to display. In this case, the file size information starts at the 20th character, so the command (and its output) look like this:
$ ls -hog | cut -c 20-
136B Jun 9 17:38 Desktop
7.4K Jun 9 17:45 Documents
136B Jun 9 07:43 Downloads
1.7K Jun 9 09:04 Library
272B May 14 19:04 Movies
170B Apr 30 06:58 Music
306B May 16 20:38 Pictures
204B May 29 17:31 Public
136B Jun 7 18:06 Sites
102B May 20 03:06 StuffIt
etc...
Today’s 10-up Tweet featured a simple improvement to the ls -al command. This command lists all files in long format, and the output is quite verbose:
$ ls -l
total 0
drwx------@ 4 Steve staff 136 Jun 9 17:38 Desktop
drwxr-xr-x@ 222 Steve staff 7548 Jun 9 17:45 Documents
drwx------@ 4 Steve staff 136 Jun 9 07:43 Downloads
drwx------@ 51 Steve staff 1734 Jun 9 09:04 Library
drwx------@ 8 Steve staff 272 May 14 19:04 Movies
drwx------@ 5 Steve staff 170 Apr 30 06:58 Music
drwx------@ 9 Steve staff 306 May 16 20:38 Pictures
drwxr-xr-x@ 6 Steve staff 204 May 29 17:31 Public
drwxr-xr-x@ 4 Steve staff 136 Jun 7 18:06 Sites
drwx------ 3 Steve staff 102 May 20 03:06 StuffIt
etc...
But if you’ve got files with lengthy names, this output can get quite wide—and the thing you may be most interested in, the filename, will be a good distance off to the right. The command line suggestion is to use ls -hog instead. This “piggie” version of ls uses three modifiers to simplify the output. The h modifier converts file sizes to human-readable form (7.4K instead of 7548). The next two options work together to eliminate both the owner (Steve) and the group (staff) from the output. When you use this version of the command, the output is much cleaner:
$ ls -hog
total 0
drwx------@ 4 136B Jun 9 17:38 Desktop
drwxr-xr-x@ 222 7.4K Jun 9 17:45 Documents
drwx------@ 4 136B Jun 9 07:43 Downloads
drwx------@ 51 1.7K Jun 9 09:04 Library
drwx------@ 8 272B May 14 19:04 Movies
drwx------@ 5 170B Apr 30 06:58 Music
drwx------@ 9 306B May 16 20:38 Pictures
drwxr-xr-x@ 6 204B May 29 17:31 Public
drwxr-xr-x@ 4 136B Jun 7 18:06 Sites
drwx------ 3 102B May 20 03:06 StuffIt
etc...
Now there’s only a bit of added information at the front—the permissions on the file, and the number of hard links (ln) to that file. If you’d rather not see those columns, you can send the output of ls to the cut command, which can trim columns from the output prior to display. In this case, the file size information starts at the 20th character, so the command (and its output) look like this:
$ ls -hog | cut -c 20-
136B Jun 9 17:38 Desktop
7.4K Jun 9 17:45 Documents
136B Jun 9 07:43 Downloads
1.7K Jun 9 09:04 Library
272B May 14 19:04 Movies
170B Apr 30 06:58 Music
306B May 16 20:38 Pictures
204B May 29 17:31 Public
136B Jun 7 18:06 Sites
102B May 20 03:06 StuffIt
etc...
0 Comments
Safari 4 Final is out
06/09/2009 07:57
Safari 4 the final release is out. The Tab bar is
back where it used to be but I like it. it’s faster
and more stable than the beta releases where. Since I
just downloaded it, I’ll have to write more on the
new browser as I get used to it. Here is a link where
you can get the latest Safari 4 final release.
http://www.apple.com/safari/
Leopard Startup Commands
06/05/2009 19:47
| Action/Explanation
|
Keystroke
|
| Eject CD on
boot
|
Hold Mouse
button down immediately after powering on
|
| OS X Safe
boot
|
Press Shift
during startup
|
| Start up in
FireWire Target Disk mode
|
Press T
during startup
|
| Startup from
a CD
|
Press C
during startup
|
| Bypass
primary startup volume and seek a different
startup volume (CD, etc.)
|
Press
Cmd-Opt-Shift-Delete during startup
|
| Choose
Startup disk before booting
|
Press Option
during startup
|
| Start up in
Verbose mode
|
Press Cmd-V
during startup
|
| Start up in
Single-User mode (command line)
|
Press Cmd-S
during startup
|
| Force
Powerbook screen reset
|
Press R
during startup
|
| Force OS X
startup
|
Press X
during startup
|
Leopard 10.5.x and X11
05/20/2009 03:27
For the past 3 days I’ve been trying like hell to get
X11 working properly on my new 24” iMac with Leopard
10.5.7. I can start the X11 console from the
Utilities folder in Applications and run the 3
programs that are listed in the Applications list
(Terminal, Xman and Xlogo) but as far as issuing
“startx” at the prompt and getting a window manager
to come up is just impossible. This Leopard install
was pre-installed with all of the latest updates and
patches from Apple so there shouldn’t be any problems
at all. Yet all I get after typing “startx” at the
prompt is a message that says:
font_cache: Scanning user font directories to generate X11 font caches
font_cache: Updating FC cache
xauth: creating new authority file /Users/Steve/.serverauth.13151
font_cache: Done
waiting for X server to begin accepting connections .
..
..
and this will go on and on until it times out. I need some suggestions here to get X11 working properly so please leave a comment if you have something useful that may help.
font_cache: Scanning user font directories to generate X11 font caches
font_cache: Updating FC cache
xauth: creating new authority file /Users/Steve/.serverauth.13151
font_cache: Done
waiting for X server to begin accepting connections .
..
..
and this will go on and on until it times out. I need some suggestions here to get X11 working properly so please leave a comment if you have something useful that may help.