bug-coreutils
[Top][All Lists]
Advanced

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

RE: Undocumented cut feature


From: Gambs, David (CONT)
Subject: RE: Undocumented cut feature
Date: Fri, 26 Oct 2007 13:40:14 -0400

Bob,

>From vi w/set list I have the following -

file3:
optvg^M$
4$
3171$

file2 (the one that I cut on):
 optvg$
 4 MB$
 3171 / 12.39 GB$

The command:
cut -f2 -d' ' ~/file2 > ~/file3

Your suggested command gives:
$ cut -f2 -d' ' file2 | od -tx1 -c
0000000 6f 70 74 76 67 0d 0a 34 0a 33 31 37 31 0a
          o   p   t   v   g  \r  \n   4  \n   3   1   7   1  \n
0000016

And I have found differences within RedHat on the vgdisplay. This
vgdisplay is in /sbin and not linked to anything. On the system where
the problem does not happen (newer coreutils & OS release) the command
is /usr/sbin/vgdisplay and is linked to lvm. Don't know where that would
make a difference though.

> When I just captured the output from vgdisplay and looked at it in vi,

> it was not there either. I had this as a straight pipe but did not get

> the vg name in the final output which had all three on a single line -

> the ^M would wipe out the vg name.

>>I don't understand.  Could you post the exact example?

cd ~
/sbin/vgdisplay | egrep -e Name -e "PE Size" -e Free | cut -b 22- | cut
-f2 -d' ' > file1
rm file.out
touch file.out
gawk '
{ line0 = /[:alpha:]/ }
{ printf "%s ", $line0 >> "file.out" }
{ getline }
{ line1 = /[:print:]/ }
{ printf "%i ", $1 >> "file.out" }
{ getline }
{ line2 = /[:print:]/ }
{ print $1 >> "file.out" } ' file1
rm file1

In the gawk script when you output line0, the ^M puts the cursor at the
beginning of the line. The next print lines then overwrite what was
there. In this case optvg is completely overwritten. A longer vg name
would have some of it left.

$ cat file.out
 4 3171

> And we are at core utilities: coreutils-4.5.3-28.4

And OS: Red Hat Enterprise Linux AS release 3 (Taroon Update 6)
Linux version 2.4.21-47.ELsmp (address@hidden)
(gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-54)) #1 SMP Wed Jul 5
20:38:41 EDT 2006

> However, the issue was cleared in coreutils-5.2.1-31.6

And OS: Red Hat Enterprise Linux AS release 4 (Nahant Update 5)
Linux version 2.6.9-55.0.6.ELsmp
(address@hidden) (gcc version 3.4.6 20060404
(Red Hat 3.4.6-8)) #1 SMP Thu Aug 23 11:11:20 EDT 2007

Good data points.  But if so then I believe it was probably related to
native language support added by the vendor.  In which case you would
need to work through your vendor to acquire a patch that would be
compatible with your system.

> I do like your method of getting the info into variables and that 
> would allow me to output things better, although I think your way will

> have an array on each variable when there is more than one vg on the 
> system (something the client has all over the place).

Ah, yes, multiple volume groups.  I had not accounted for that in my
example.  Good observation.

And all this started on HP-UX. The script works just fine there. It was
when I brought it over to Linux that problems arose and modifications
had to be made.


- dmg



The information contained in this e-mail is confidential and/or proprietary
to Capital One and/or its affiliates. The information transmitted herewith
is intended only for use by the individual or entity to which it is 
addressed.  If the reader of this message is not the intended recipient, 
you are hereby notified that any review, retransmission, dissemination, 
distribution, copying or other use of, or taking of any action in reliance 
upon this information is strictly prohibited. If you have received this 
communication in error, please contact the sender and delete the material 
from your computer.





reply via email to

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