Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

issue with ls

Status
Not open for further replies.

balajipn

Programmer
Mar 30, 2004
65
IN
Hi,

I am working on IBM-AIX version 4.3. We are having a directory called /met/le which contains a number of programs with .bv extension. My issue is this. If I try to list all the *.bv files with the command "ls -ltr *.bv", I am getting an error message "sh: /usr/bin/ls: 0403-027 The parameter list is too long.". Is there anyway to overcome this?. I don't want to use the find command as the directory /met/le has got lot of subdirectories with the a number of *.bv files.

Do let me know if any one has got an answer for this.

Thanks in Advance,
Balaji.

 
ls | grep '.bv$' | xargs ls -ltr

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Thanks for the help. However, I am pasting the result below.

1 src page 1333 Apr 24 2001 adrcod.bv.bne
1 src page 19688 Apr 24 2001 comp_lebv.sh
1 bne page 2041 Jun 11 2001 cusdis.bv.bne
1 khd page 19169 Jun 11 2001 bopini.bv.cha
1 bne page 8482 Jun 13 2001 ecicus.bv.bne
1 bne page 17939 Jun 14 2001 eciexp.bv.bne
1 bne page 2802 Jun 21 2001 crdump.bv.27june
1 bne page 7545 Jul 12 2001 ecicon.bv.july13
1 bne page 14024 Jul 12 2001 eciadr.bv.july13
1 bne page 8994 Jul 12 2001 ecicus.bv.july13
1 sdv page 14103 Jul 13 2001 eciadr.bv.sdv
1 sdv page 7627 Jul 13 2001 ecicon.bv.sdv
1 sdv page 8977 Jul 13 2001 ecicus.bv.sdv
1 vpa page 7323 Jul 17 2001 brigarsht.bv.vpa
1 bne page 4771 Jul 17 2001 ecidmpcus.bv.bne
1 vpa page 7323 Jul 24 2001 brigarsht.bv.0724
1 aka page 26190 Aug 06 2001 edwcus.bv.bne
1 src page 86914 Aug 07 2001 ackful.bv.032204
1 sky page 26387 Aug 07 2001 edwcus.bv.aka
1 sky page 26133 Aug 07 2001 edwcus.bv.sky
1 aka page 27328 Aug 12 2001 edwcus.bv.aar
1 src page 125787 Aug 14 2001 dfw_le1pkg.bv

As you see, the above command has listed the files that contains the word bv. How do I get only the list of .bv files?. I guess it could be acheived using grep command in some way.

Thanks again.

Balaji.

 
Works fine on 4.3.3 here.

Your results are what you would get without the the dollar sign in the grep pattern, which indicates that match must take place at the end of the line. You didn't leave it off, did you?



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
I get the same results irrespective of the presence of $ sign after the "bv".

Thanks,
Balaji.
 
What's the output of the following?

ls -l `which grep`




Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Try using egrep with the same argument.

BTW, I was interested in the file size of grep, not just the location.

This is puzzling. Maybe it's related to locale. What's the environmental variable LANG set to?


Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
This is the output of which grep

3 bin bin 20526 Sep 16 2001 /usr/bin/grep

I removed the permission list from the above line.

locale is set to en_US only.

egrep is also producing the same results. Really puzzling.

 
Ok, how about:

lslpp -l bos.rte.commands

I'm at 4.3.3.75. I see that there was a fix applied relating to '$' hanging in certain situations, at version 4.3.3.76. I suspect that if you're at an earlier level, there's a PTF you need, and if you're at a higher level, the fix for the hang broke this behaviour.

I also expect, given this problem so far, to find that you're running the exact same level as me. :)



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
We are using the AIX version 4.3.3.

Not sure whether we have the $ bug in it.
 
I was referring to the level of the package containing the grep command. Please run the lslpp command I posted.



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
This is my resultset.

Fileset Level State Description
-----------------------------------------------------
Path: /usr/lib/objrepos
bos.rte.commands 4.3.3.79 APPLIED Commands

Path: /etc/objrepos
bos.rte.commands 4.3.3.79 APPLIED Commands

 
Hey,

I found something interesting. When I execute the command "ls | grep '.bv$' | xargs ls -ltr" from the command line, I am getting the results as I shown in my initial reply.

However, when I include the above command in a script, it seems to be working fine. I am getting the results what I expected. See the results below.

1 src page 125787 Aug 14 2001 dfw_le1pkg.bv
1 vpa page 1808 Aug 17 2001 dbm4.bv
1 krs page 7388 Aug 17 2001 eotrsp.bv
1 krs page 7487 Aug 17 2001 eotruc.bv
1 met page 19377 Aug 20 2001 bopini.bv
1 met page 24308 Aug 20 2001 bopsim.bv
1 ceh page 2589 Aug 20 2001 cehdlei.bv
1 ceh page 2290 Aug 20 2001 cehdsdt.bv
1 sky page 2041 Aug 21 2001 cusdis.bv
1 sky page 909 Aug 21 2001 edwcustrmcd.bv
1 sky page 917 Aug 21 2001 edwcusshipvia.bv
1 sky page 939 Aug 21 2001 edwcusmail.bv
1 sky page 935 Aug 21 2001 edwconmail.bv
1 sky page 924 Aug 21 2001 edwcuscrdlcd.bv
1 sky page 935 Aug 21 2001 edwadrmail.bv
1 khd page 2805 Aug 21 2001 cehdumplei.bv
1 met page 7913 Aug 22 2001 dmpmkt.bv
1 abu page 4972 Aug 22 2001 edwcusdefcnt1.bv
1 abu page 4972 Aug 22 2001 edwcusdefcnt.bv
1 ceh page 3020 Aug 23 2001 cehdumpsdt.bv
1 pdo page 1291 Aug 23 2001 autofrc.bv
1 met page 2703 Aug 23 2001 cusupdate.bv
1 ceh page 643 Aug 23 2001 cehupdsdt.bv

However, the order of listing is different between the initial result.

Not sure why it is behaving like this.

By any chance, could it be a bug in AIX?.

Thanks,
Balaji.
 
There are notes related to grep on several PTFs applied to bos.rte.commands, starting with 4.3.3.76, which specifically involved the dollar sign (although in relation to the -w switch). I suspect that this is the all too common case of a fix having unintended side effects.

Now, how to do your listing without grep.

This should do it, in KornShell:

Code:
ls -tr| while read filename
do
  if [ "${filename}" != "${filename%.bv}" ]
  then
    ls -l ${filename}
  fi
done

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top