Tuesday, September 11, 2012

Update mysql table records, which contain umlaut

Use your database and run this MySQL command for your desired Table:

UPDATE YOUR_TABLE SET YOUR_FIELD = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(YOUR_FIELD,'ä','ae'),'Ä','Ae'),'ö','oe'),'Ö','Oe'),'ü','ue'),'Ü','Ue');

Rename files- & directories-name which contains umlaut

I would like to change the file name, which contains umlaut, with normal characters:

For example: ü with ue or Ä with Ae.

Here is my commands:

for i in `find -name '*ü*'`; do mv $i `echo $i | sed 's/ü/ue/'`; done
or
for i in `find -name '*Ä*'`; do mv $i `echo $i | sed 's/Ä/Ae/'`; done

and the following command for the directories:
for i in `find -type d -name '*Ä*'`; do mv $i `echo $i | sed 's/Ä/Ae/'`; done


Wednesday, September 5, 2012

Bash script - Delete characters before or after a pettern from string

I have this string:

MyString="This is a Test. Isn't it? Yes, it is."

I want to delete all characters after "?":

echo $MyString | sed -e 's/?.*//g'

the result is: This is a Test. Isn't it

now I want to delete all characters before "a":

echo $MyString | sed -e 's/.*a//g'

Resut: Test. Isn't it? Yes, it is.




Bash script - Removing duplicated lines from file

Run this command:

awk '!x[$0]++' source.txt > target.txt