RE: upper/lower case

"[email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Since this is a "sed" site, I was hoping you would try out the sed solutions provided here :-\ 

 

 >    perl -F\; -pale  '
 >             s/\b(\w+)/\u\L$1/g for $F[2];
>             $_=join";",@F;
>    '   yourfile

 

 

 perl options -F field separator is ; since your csv file is semicolon delimited.
 

 -a turns on the autosplit mode where the input lines are split on the field separator specified by the -F option.
 

 -p turns on the autoprint mode, similar to "sed's" default behavior.
 

 -l turns on the auto-chomp & auto-newline mode, similar to "sed's".
 

 Now each line is split up into an array of fields @F, which are individually 
 accessed as:
    $F[0] as the 1st field
    $F[1] as the 2nd field
    $F[2] as the 3rd field
    ... 
 

 Since you mentioned the column of interest is the third, so $F[2] is the
 field variable we'd be interested in. In case you wanted column 9, then look
 at $F[8].
 

 the substitute command s/// is similar to the sed command
 

 Once you transform the @F field then join them back to the pattern space
 and let the the -p option print it for you.
 

 HTH
 

 -Rakesh
 

---In [email protected], <rachid.mokrani@...> wrote :

 Hi Rakesh,
 
 Your perl exemple work great. 
 
 perl -F\; -pale '
 s/\b(\w+)/\u\L$1/g for $F[2];
 $_=join";",@F;
 ' yourfile
 
 Could you explain it ?
 
 Where are you specify the colum number to apply this perl command ? 
 If I want to apply this command on the colum 9 or 7 etc.... how to do it ?
 
 
 Personally I prefer sed/awk. But if I did not find I will keep this perl command.
 
 Thanks very much.
 
 
 -----Message d'origine-----
 De : [email protected] mailto:[email protected] [mailto:[email protected] mailto:[email protected]] 
 Envoyé : vendredi 11 décembre 2015 09:08
 À : [email protected] mailto:[email protected]
 Objet : Re: upper/lower case
 
 
 
 Since you don't have GNU sed, you could perform your transformation utilizing the regular sed as follows:
 
 
 sed -e '
 h
 s/;/\
 /3
 s/\n.*//
 s/;/\
 /2
 s/.*\n//
 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
 s/\<\([a-z]\)/\
 \1/g
 s/$/\
 /
 s//\
 aA/
 s//\
 bB/
 s//\
 cC/
 s//\
 dD/
 s//\
 eE/
 s//\
 fF/
 s//\
 gG/
 s//\
 hH/
 s//\
 iI/
 s//\
 jJ/
 s//\
 kK/
 s//\
 lL/
 s//\
 mM/
 s//\
 nN/
 s//\
 oO/
 s//\
 pP/
 s//\
 qQ/
 s//\
 rR/
 s//\
 sS/
 s//\
 tT/
 s//\
 uU/
 s//\
 vV/
 s//\
 wW/
 s//\
 xX/
 s//\
 yY/
 s//\
 zZ/
 
 
 :a
 s/\n\(a\)\(.*\)\(\n.*\n\1\)\(A\)\(.*\)/\4\2\3\4\5/;ta
 s/\n\(.\)\(.*\)\(\n\n.*\n\1\)\(.\)\(.*\)/\4\2\3\4\5/;ta
 
 
 x;G;s/\n\n.*//
 s/;/\
 /3
 s/;/\
 /2
 s/\n\(.*\)\n\(.*\)\n\(.*\)/;\3;\2/
 ' yourfile
 
 
 
 
 
 with Perl it can be accomplished in a much simplified manner:
 
 
 perl -F\; -pale '
 s/\b(\w+)/\u\L$1/g for $F[2];
 $_=join";",@F;
 ' yourfile
 
 
 HTH
 
 
 -Rakesh
 
 
 
 
 
 
 
 [Non-text portions of this message have been removed]
 
 
 
 ------------------------------------
 Posted by: sharma__r@... mailto:sharma__r@...
 ------------------------------------
 
 -- 
 
 ------------------------------------
 
 Yahoo Groups Links
 
 
 
 __________________________
 Avant d'imprimer, pensez à l'environnement ! Please consider the environment before printing ! 
 Ce message et toutes ses pièces jointes sont confidentiels et établis à l'intention exclusive de ses destinataires. Toute utilisation non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. IFP Energies nouvelles décline toute responsabilité au titre de ce message. This message and any attachments are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. IFP Energies nouvelles should not be liable for this message.
 __________________________


 
  



[Non-text portions of this message have been removed]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.