3,058 reputation
1529
bio website None
location United States
age 53
visits member for 5 years
seen Jul 21 at 6:51
Long-time Informix user and developer, experienced in C and Unix (many variants). Email: jonathan.leffler@gmail.com

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
25
answered Why can't I mv a file?
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
revised What does this mean? $ . test.sh
Clarify slightly
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
answered What does this mean? $ . test.sh
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.)
Mar
22
answered Rename a file based on the owner - linux/Unix
Feb
18
awarded  linux
Feb
14
awarded  Notable Question
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.
Jan
10
answered What does -p do on shell script?
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.