bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nl command line option not recognized


From: Eric Blake
Subject: Re: nl command line option not recognized
Date: Mon, 16 Mar 2009 10:31:34 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[re-adding the list, so that the archives see the resolution of this thread]

According to Emmanuel Dumont on 3/16/2009 10:18 AM:
> Hi Eric
> 
> Thanks for feed back.
> 
>> A bit of overkill.  When stdout of ls is not a terminal, then the -1
>> option is redundant.  And globbing * can run into command line length
>> limitations, which are avoided if you use a listing of . (or the implicit
>> default of ls).  In other words, this is equivalent:
>>
>> ls | nl --first-page=2
>>
>>   
> You're right, I did add -1 option because my ls was aliased to ls -C
> for the globbing, I was actually specifying a filename like filename.*.*
> (like an image sequence)
> But I realise that the command line length limitation can come into play
> in that case too. might consider using xargs maybe
> (how many files in the sequence would be too much?)

echo filename.*.* | xargs nl --starting-line-number=2

will proceed to chunk your listing into the fewest number of necessary
processes, although you will then have to deal with the fact that each
instance of nl starts its numbering over again.  And by using echo (a
shell builtin) instead of ls (an external process), you are using one less
process.  But that does not deal with newlines in the glob, so you may
want to use GNU findutils, and:

find -maxdepth 1 -name 'filename.*.*' -print0 \
 | xargs -0 nl --starting-line-number=2

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm+fuYACgkQ84KuGfSFAYAE1ACgueFskresj7tn0V2kwJf4mQtI
RX8AoIHWYYe9XlSo2ALCR5fE6gJT7vjz
=KXwD
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]