1833804 Members
2646 Online
110063 Solutions
New Discussion

string manipulatoin

 
Unix Administrator_5
Frequent Advisor

string manipulatoin

I am using command substitution to obtain a user's distinguished name. In the command I have tried awk and cut just to get a portion of the dn. I recieve a correct string if under 75 characters, if 75 or more then the string with awk is dropped at that point or with cut there is a space and the 73 and 74 cahracter is repeated and the rest of the string is returned. Is there a work around to this?
6 REPLIES 6
Marco Paganini
Respected Contributor

Re: string manipulatoin

Hello,

Could you please post the actual data and the program/shell script here for us to take a look?

Regards,
Paga
Keeping alive, until I die.
A. Clay Stephenson
Acclaimed Contributor

Re: string manipulatoin

Hi:

You don't mention what OS version you are running but most awk's have at least a 1024 characters/field limit so you should have no problem using split or substr.

I can absolutely assure that perl can handle this.
If it ain't broke, I can fix that.
Darrell Allen
Honored Contributor

Re: string manipulatoin

Hi,

How about using:
awk -F: '/userid/ {print $5}' /etc/passwd | awk -F, '{print $1}'

The second awk strips off the location and phone stuff from the gcos field.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
G. Vrijhoeven
Honored Contributor

Re: string manipulatoin

Hi,

cat /etc/passwd | awk -F: '{print $5}'

this should work.

Gideon
Unix Administrator_5
Frequent Advisor

Re: string manipulatoin

It seems there is a problem with the string I am returning. It must have a newline character at the 75th position.

Now the question is how do I strip that character out when I process it?
Darrell Allen
Honored Contributor

Re: string manipulatoin

Hi again,

I believe it's back to Marco's request for more info. Would you please post what you are trying to do?

Thanks,
Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)