Afficher un message
Vieux 22/08/2006, 13h58   #13
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Access 1st 12 charectors of a word.

Dave Kelly wrote:
> Dave Kelly wrote:
>
>> I have a list that is 3 words to each line.
>> I know how to read the file.
>> I need only the first 12 character of the 3 word. This word is not
>> guaranteed to be 12 character long. This is where I'm stuck.
>>
>> Is there an equivalent to the old basic 'left$'? Where do I find it?
>>
>> What do I search Google for?
>>
>> TIA Dave

>
> Works great, Thanks guys.
>
> This command line:
>
> ./pdlist.sh < TFF-Membership-8-19-06.csv > pdlist
>
> #!/bin/bash
>
>
> main()
> {
> IFS=, ; while read "LastName" "FirstName" "Address" "City" "State" \
> "ZipCode" "HomePh" "BusinessPh" "tmp" "DateJoined" "email" \
> "MembershipType" "RenewalDate" "MembershipYear" "Paid" "Notes";
>
> do make_list "$LastName" "$FirstName" "$email" ; done
> }
> make_list()
> {
> lastname=$1;
> firstname=$2;
> email=$3;
>
> Email=$(echo "$email" | cut -c-12)
> echo "$firstname$lastname",$Email;
> }
> main
>
> produced my own entry in the list as such.
> Exactly what I wanted.
>
>
> DaveKelly,daveekelly@e
>
> again, Thanks
> Dave
>


awk -F, '{ printf "%s%s,%s\n", $1,$2,substr($3,1,12) }' <
TFF-Membership-8-19-06.csv > pdlist

would do the same.

Ed.
  Réponse avec citation
 
Page generated in 0,05171 seconds with 9 queries