Re: upper/lower case

"Daniel Goldman [email protected] [sed-users]" <[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
In the version I sent, it had three lines, one per cut command:

cut -d ";" -f $col_to_sed $input_file > old_col.txt
cut -d ";" -f 1-$prev_col $input_file > cols_before.txt
cut -d ";" -f $next_col- $input_file > cols_after.txt

In the version you sent back (and apparently received), it has only one 
line, the three lines are glommed together:

cut -d ";" -f $col_to_sed $input_file > old_col.txt cut -d ";" -f 
1-$prev_col $input_file > cols_before.txt cut -d ";" -f $next_col- 
$input_file > cols_after.txt

Could you double-check it's three separate "cut" lines in your shell 
script, let us know, and try again?

BTW, cut and paste are quite useful, IMO.

Thanks,
Daniel

PS - The other negative about my proposed solution is that it's not 
short, not even near a one-liner. However, I think it's manageable.

On 12/11/2015 7:43 AM, MOKRANI Rachid [sed-users] wrote:
>
> And Daniel suggestion retrun me.
>
> cat input.txt
> "a";"b";"c";"d";"e";"f"
> "9515";"CRAIG";"PAUL";"3 Av Marie Curie";"75001";"Paris"
> "355";"BROSNAN";"MARIE ODILE";"43 Rue PASTEUR";"75001";"Paris"
> "85";"CONNERY";"JEAN-CHARLES";"7 Rue LECOURBE";"14256";"Seville"
> "5315125";"MOORE";"JEAN-MARC";"12 Av PASTEUR";"47852";"Rome"
>
>
> cat process.sh
> #!/bin/sh
> input_file=$1
> col_to_sed=$2
> prev_col=`expr $col_to_sed - 1`
> next_col=`expr $col_to_sed + 1`
> cut -d ";" -f $col_to_sed $input_file > old_col.txt cut -d ";" -f 1-$prev_col $input_file > cols_before.txt cut -d ";" -f $next_col- $input_file > cols_after.txt
> sed -r "1! {s/(.*)/\L\1/; s/\<(.)/\u\1/g}" < old_col.txt > new_col.txt
> paste -d ";" cols_before.txt new_col.txt cols_after.txt
>
> return me.
>
> ./process.sh input.txt 3
> cut: only one type of list may be specified
> Try 'cut --help' for more information.
>
>
>
> -----Message d'origine-----
> De : [email protected] [mailto:[email protected]]
> Envoyé : vendredi 11 décembre 2015 13:06
> À : [email protected]
> Objet : Re: upper/lower case
>
> Thanks for sending the more complete file example. Here is one way to do it, in addition to the other suggestions.
>
> $ cat input.txt
> "id";"lastname";"firstname";"adress";"zip";"town"
> "9515";"CRAIG";"PAUL";"3 Av Marie Curie";"75001";"Paris"
> "355";"BROSNAN";"MARIE ODILE";"43 Rue PASTEUR";"75001";"Paris"
> "85";"CONNERY";"JEAN-CHARLES";"7 Rue LECOURBE";"14256";"Seville"
> "5315125";"MOORE";"JEAN-MARC";"12 Av PASTEUR";"47852";"Rome"
>
> $ cat process.sh
> input_file=$1
> col_to_sed=$2
>
> prev_col=`expr $col_to_sed - 1`
> next_col=`expr $col_to_sed + 1`
>
> cut -d ";" -f $col_to_sed $input_file > old_col.txt cut -d ";" -f 1-$prev_col $input_file > cols_before.txt cut -d ";" -f $next_col- $input_file > cols_after.txt
>
> sed -r "1! {s/(.*)/\L\1/; s/\<(.)/\u\1/g}" < old_col.txt > new_col.txt
>
> paste -d ";" cols_before.txt new_col.txt cols_after.txt
>
> $ ./process.sh input.txt 3
> "id";"lastname";"firstname";"adress";"zip";"town"
> "9515";"CRAIG";"Paul";"3 Av Marie Curie";"75001";"Paris"
> "355";"BROSNAN";"Marie Odile";"43 Rue PASTEUR";"75001";"Paris"
> "85";"CONNERY";"Jean-Charles";"7 Rue LECOURBE";"14256";"Seville"
> "5315125";"MOORE";"Jean-Marc";"12 Av PASTEUR";"47852";"Rome"
>
> On the negative side, the shell script might need to be modified if you have cases where col_to_sed is the first or last column, so the script would end up more complicated.
>
> On the positive side, it works, and (at least to me!) seems simple enough to understand and maintain.
>
> Daniel
>
> On 12/11/2015 12:34 AM, MOKRANI Rachid [sed-users] wrote:
>> Hi,
>>
>> Thanks, but this solution (without -i)  show me the result and don't write/save the file.
>>
>> This is a file exemple. the original file has many more rows and
>> columns
>>
>> "id";"lastname";"firstname";"adress";"zip";"town"
>> "9515";"CRAIG";"PAUL";"3 Av Marie Curie";"75001";"Paris"
>> "355";"BROSNAN";"MARIE ODILE";"43 Rue PASTEUR";"75001";"Paris"
>> "85";"CONNERY";"JEAN-CHARLES";"7 Rue LECOURBE";"14256";"Seville"
>> "5315125";"MOORE";"JEAN-MARC";"12 Av PASTEUR";"47852";"Rome"
>>
>>
>> in my example I would apply the results of sed  (sed -i -r "s/(.*)/\L\1/; s/\<(.)/\u\1/g" )  only in column 3 (title firstname) .
>>
>> "id";"lastname";"firstname";"adress";"ZIP";"TOWN"
>> "9515";"CRAIG";"Paul";"3 Av Marie Curie";"75001";"Paris"
>> "355";"BROSNAN";"Marie Odile";"43 Rue PASTEUR";"75001";"Paris"
>> "85";"CONNERY";"Jean-Charles";"7 Rue LECOURBE";"14256";"Seville"
>> "5315125";"MOORE";"Jean-Marc";"12 Av PASTEUR";"47852";"Rome"
>>
>>
>> Once obtained this result I could apply a sed command on the column of my choice.
>>
>> And for now I just can't  do it.  :-(
>>
>
>
> ------------------------------------
> Posted by: Daniel Goldman <[email protected]>
> ------------------------------------
>
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.