3,058 reputation
1429
bio website None
location United States
age 53
visits member for 4 years, 11 months
seen Jul 2 at 16:19
Long-time Informix user and developer, experienced in C and Unix (many variants). Email: jonathan.leffler@gmail.com

Oct
24
comment confused about file owner in linux
Root is unfettered by such trivial details as 'does the user belong to the group'. At the o/s level, there is no such enforcement.
Oct
24
comment confused about file owner in linux
That's normally, but not necessarily, the case. It might be that the directory sets the group permission (SGID bit), while the user has write permission to the directory (perhaps public write permission, perish the thought, unless the directory has the sticky bit set; or perhaps because of ACLs). But in the normal case, a file is created belonging to the effective GID of the process that creates the file.
Oct
13
comment How to recover file from 'hidden' directory with Time Machine?
Thanks again for this answer — I needed to restore a .git directory and needed to use this again.
Jun
18
comment How can I make `find` find files in reverse chronological order?
You can't make find do anything in a particular sorted order, beyond choosing between a depth-first search and a breadth-first search.
Jun
7
comment UNIX: Merging files with different extensions to one file
I could see it listing the message file before the XML file for each pair, but I really don't see how cat * could list all the XML files before all the message files. Can you elaborate on that? (Also, your cat command has no pipes whatsoever; it only uses I/O redirection.)
Jun
7
comment UNIX: Merging files with different extensions to one file
There's no reason why a shell programming question cannot be asked on SO.
Jun
2
comment How to compare files in different folders in Unix?
And the -b like the question?
May
25
comment Why can't I mv a file?
Be grateful you copied the trailing slash. Without that, you'd have had a file /Library/Receipt and the original version of the file /Library/Receipts/InstallHistory.plist, and that would lead to further confusion down the road. And let he who has never made a similar mistake cast the first stone — and when that stone is lobbed, I'll show you a rank novice programmer. Nevertheless, I don't think this Q&A is going to be a lot of help to future users.
May
8
comment print specific line and then some more
Note that if the patterns appears in the next 10 lines, you should (probably) reset the 'print counter'. Or design it so that when you find the match, you set max_print = NR + 10; and then for each line, if (NR < max_print) print
May
6
comment quick tail on a huge file on linux
How long, roughly, is each line (or how big is the file in bytes)? Are the lines reasonably uniform in size, or are there short ones and long ones to worry about? If the standard tool won't do the job timely, then you will probably need to write your own. It is exasperating that you'll probably need to scan the tail end of the file at least twice, but probably unavoidable.
Mar
23
comment What does this mean? $ . test.sh
@chepner: That's entirely plausible. I haven't bothered to experiment with whether the current directory is searched first or last. For the most part, it is not important to this question, which is about the high-level difference between sourcing and executing a script. I agree, though, that it does matter if you're going to make a bullet-proof system depending on such a script.
Mar
23
comment What does this mean? $ . test.sh
The dot command pre-dates the source command by years. It was in the original Bourne shell. The C shell had the source command for the same job; bash imported that as a synonym for . some time later.
Mar
22
comment Rename a file based on the owner - linux/Unix
The + is useful when you want to provide a list of file names to a single invocation of the command. Here, though, you want to execute each mv with just two arguments (old name and new name), so you need to execute mv once for each file that's found. Or you use a more complex rename command, such as a Perl-based one that can do a regex mapping, so -exec rename 's/^/s/' {} + is now appropriate. (Beware: there are several sub-species of command called rename, and they're mostly feeble by comparison with the Perl-based one.)
Feb
9
comment How can I prevent bash from executing 'rm' when ' * ' is one of the arguments?
I don't think relying on an alias for rm is a good idea. You'll get caught without the alias sometime, but you'll still be relying on its protection, and all hell will break loose. It is better to learn to think "rm is dangerous; let me check my command line" than to rely on a crutch.
Jan
30
comment Error when installing cpanminus on Mac OS X
Personally, I never modify the system's installation of Perl; I never use it, either. I always build my own so that I can be as up-to-date as I choose. But that's just me.
Jan
30
comment Error when installing cpanminus on Mac OS X
If the spaces or tabs in /System/Library/Perl/5.12/darwin-thread-multi- 2level/CORE/config.h are not an artefact of the way you're copy'n'pasting, then you need to find out why you have the spaces or tabs in the name. If they are an artefact, then you need to investigate why you don't have /System/Library/Perl/5.12/darwin-thread-multi-2level/CORE/config.h present. It's there OK on my Mac OS X 10.7.5 machine — though I'm using my own Perl 5.16.2 rather than the system Perl 5.12.3. I can trade perl -V output with you if you think that will help.
Jan
10
comment What does -p do on shell script?
@umlaeute: bash does have a -p option.
Dec
26
comment OS X Terminal command line prompt hostname changed to unknownXXXXXXXXXXXX
Based on the blog referenced in joerick's answer, it is likely that your DHCP or BootP server, or the reverse DNS lookup, is yielding the unknown<MAC address> (where that MAC is unrelated to it being a Mac). So, look to your network infrastructure for an explanation.
Dec
26
comment OS X Terminal command line prompt hostname changed to unknownXXXXXXXXXXXX
The x-ref'd blog entry is a little dated, unfortunately. On my (slightly dated) 10.7.5, the /etc/hostconfig file contains (slash for newline): # This file is going away / AFPSERVER=-NO- / AUTHSERVER=-NO- / TIMESYNC=-NO- / QTSSERVER=-NO-. Note that there is no HOSTNAME entry as mentioned in the blog. However, the name determination sequence (DHCP or BootP, Reverse DNS, System Preferences, localhost) is likely to be close to the algorithm used.
Dec
26
comment OS X Terminal command line prompt hostname changed to unknownXXXXXXXXXXXX
Welcome to Stack Overflow. Have you rebooted? Have you restarted terminal? Do you run any Ruby in your profile? How does your computer identify itself? Simply installing RoR should not affect your terminal at all. Your question is in danger of being closed as 'off topic'; it is border-line on topic here in my view. You might get a more receptive response on the Apple Stack Exchange site, but they'll likely want to know answers to the questions I raised.