Go Back   Talk Root - PC Hardware, Software and Web Development forums > Operating Systems > UNIX Discussion



UNIX Discussion Discuss the unix enviroment server and client side

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
  #1  
Old 05-17-2005, 02:55 PM
deepstructure@gmail.com
Guest
 
Posts: n/a
Default Re: arg list too long

Jeffrey Ross wrote:
> The other more general method is:
>
> ls | # to get all the files in the current

directory
> grep "\.class$" | # to filter out all except ones ending ".class"
> xargs ls -l # to append those files to "ls -l" in batches

keeping
> under the maximum argument size
>
> Regards,
> Jeffrey.



does this work under csh as well? i'm going crazy trying to find a
workaround for this error. i work for a vfx film house in los angeles
and im constantly needed to grab info from a range of frames
(represented as individual files), like so:

092_comp_01_shp.0935.cin
092_comp_01_shp.0936.cin
092_comp_01_shp.0937.cin
092_comp_01_shp.0938.cin
092_comp_01_shp.0939.cin
092_comp_01_shp.0940.cin


so for instance, to find the 25th file in from the end of the range i'd
do normally do this:

set last = `ls -1 *.*.cin | tail -25 | head -1`

which usually works fine - until i get a shot with a LOT of frames
(like the above example), in which case i get the "arg list too long"
error.

so i attempted to implement jeffrey's solution thusly:

set last = `ls -1 *.*.cin | xargs ls | tail -25 | head -1`

and i get this:

father 16% set last = `ls -1 *.*.cin | xargs ls | tail -25 | head -1`
/sbin/ls: Arg list too long.
father 17% echo $last
092_comp_01_shp.0916.cin

so it works, but i still get the error msg. what am i doing wrong? i
freely admit i have no idea how xargs works and the man page (like most
of them), is depressingly cryptic and dense. any help is appreciated
(even if i am in the wrong group - is there a csh group?)

cheers
christopher

Reply With Quote
  #2  
Old 05-17-2005, 02:55 PM
Hans-Joachim Ehlers
Guest
 
Posts: n/a
Default Re: arg list too long

[email]deepstructure@gmail.com[/email] wrote in
news:1111470754.951758.38930@f14g2000cwb.googlegro ups.com:

> Jeffrey Ross wrote:
>> The other more general method is:
>>
>> ls | # to get all the files in the current

> directory
>> grep "\.class$" | # to filter out all except ones ending ".class"
>> xargs ls -l # to append those files to "ls -l" in batches

> keeping
>> under the maximum argument size
>>
>> Regards,
>> Jeffrey.

>
>
> does this work under csh as well? i'm going crazy trying to find a
> workaround for this error. i work for a vfx film house in los angeles
> and im constantly needed to grab info from a range of frames
> (represented as individual files), like so:
>
> 092_comp_01_shp.0935.cin
> 092_comp_01_shp.0936.cin
> 092_comp_01_shp.0937.cin
> 092_comp_01_shp.0938.cin
> 092_comp_01_shp.0939.cin
> 092_comp_01_shp.0940.cin
>
>
> so for instance, to find the 25th file in from the end of the range i'd
> do normally do this:
>
> set last = `ls -1 *.*.cin | tail -25 | head -1`
>
> which usually works fine - until i get a shot with a LOT of frames
> (like the above example), in which case i get the "arg list too long"
> error.
>
> so i attempted to implement jeffrey's solution thusly:
>
> set last = `ls -1 *.*.cin | xargs ls | tail -25 | head -1`
>
> and i get this:
>
> father 16% set last = `ls -1 *.*.cin | xargs ls | tail -25 | head -1`
> /sbin/ls: Arg list too long.
> father 17% echo $last
> 092_comp_01_shp.0916.cin
>
> so it works, but i still get the error msg. what am i doing wrong? i
> freely admit i have no idea how xargs works and the man page (like most
> of them), is depressingly cryptic and dense. any help is appreciated
> (even if i am in the wrong group - is there a csh group?)


you get the same error because "ls -1 *.*.cin" will give you the error.
Keep in mind that what you type on the command line IS NOT nessessary what
the shell will execute.

With a ksh shell just set ( set -x ) on the command line and you will see
what a "ls /tmp/* " is really.

But to solve our problem:

ls -l | grep "\.cin$" | tail -25 | head -1

should do the job

ls -l :will show everything but you do not get the " arg list to long "
error
grep "\.cin$" : will match everything that ends with ".cin"

HTH
Hajo


Reply With Quote
  #3  
Old 05-17-2005, 02:55 PM
deepstructure@gmail.com
Guest
 
Posts: n/a
Default Re: arg list too long

hey thanks. i just have one question - what does the $ stand for in
that line? im using csh, and $ is the variable call. what is it doing
here?

thanks for your help! much appreciated.

Reply With Quote
  #4  
Old 05-17-2005, 02:55 PM
Hans-Joachim Ehlers
Guest
 
Posts: n/a
Default Re: arg list too long

[email]deepstructure@gmail.com[/email] wrote in
news:1111561124.878648.44410@z14g2000cwz.googlegro ups.com:

> hey thanks. i just have one question - what does the $ stand for in
> that line? im using csh, and $ is the variable call. what is it doing
> here?
>
> thanks for your help! much appreciated.
>


The "$" means End of File
The "^" means Begin of File

Example:
You have two files in your directory
../start.end
../start.end.bkp
../next.start

Now you would like to match only files that ENDS with ".end"


ls | grep "\.end" would match both files ( lines )
ls | grep "\.end$" would match ONLY files (lines )that ENDS with ".end"

ls | grep "^start\." would match ONLY files (lines) begining with "start."

So the $ means for your shell a variable ( If a letter follows it ) but it
does has a different meaning for grep,sed a.s.o


Happy Programming
Hajo




Reply With Quote
Reply

Bookmarks
Sponsored Links
FatCow $88 Plan for $66 only Host Unlimited Domains on 1 Account Professional Hosting from Just Host


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Social Bookmarking List kapilmark Search Engine Optimization 0 10-19-2009 12:04 PM
List of web hosts that support Java!!! AutoBan Web Hosting Discussion 2 05-04-2009 06:16 AM
Honest List of good Hosts lasurit Web Hosting Discussion 3 02-06-2009 12:43 AM
Big List of Ad Networks Steve Advertising & Affiliate Programs 4 03-21-2007 09:44 PM
China Factory Nike Wholesale Suppliers Contacts RokkerJon Announcements, Suggestions, & Feedback 0 09-03-2006 01:27 PM


All times are GMT -7. The time now is 10:54 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
© 2008 TalkRoot.com