replace etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
replace etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

18 Mart 2019 Pazartesi

Python2 - Replace Turkish characters with ascii look-alikes

#!/usr/bin/python -tt
# -*- coding: utf-8 -*-

import codecs
import sys
from base64 import b64encode#reload()
#sys.setdefaultencoding("utf-8")

UTF8Writer = codecs.getwriter('utf8')
sys.stdout = UTF8Writer(sys.stdout)

def TRreplacer(mmm):
   my_dict = dict({u'ğ':"g", u'ş':"s", u'ç':"c", u'ü':"u", u'ı':"i", u'ö':"o", u'Ö':"O", u'Ğ':"G", u'Ş':"S", u'Ç':"C", u'Ü':"U", u'İ':"I"})

   for items in my_dict:
       mmm=mmm.replace(items,my_dict[items])
   return mmm

print TRreplacer(u'YİĞİT ÖZEN')

20 Kasım 2017 Pazartesi

Batch - Değişkenler ile Replace

@echo off
setlocal enabledelayedexpansion
set string=Uzun bir cumle
set find=Uzun
set replace=Kisa
call set string=%%string:!find!=!replace!%%
echo %string%

Output = Kisa bir cumle

Batch - String'den silme

@echo off
set string=Uzun bir cumle
set string=%string:Uzun=%
echo %string%

Output = bir cumle

10 Kasım 2017 Cuma

Batch - Replace

@echo off
set string=This is my string.
set string=%string:my=your%
echo %string%

3 Temmuz 2012 Salı

Unix - sed örnekleri

string1'i string2 ile değiştir:
sed 's/string1/string2/g'

 # ile baslayanlari sil:
sed -e '/^#/d' dosya_adi

6 ile bitenleri sil:
sed -e '/6$/d' dosya_adi

2 uzunluklu satirlari sil:
sed -e '/^..$/d' dosya_adi

5 ile başlayanları bas:
sed -n "/^5/p" file

ilk satıırı sil:
sed -e '1d' /etc/services | more
 
Modify anystring1 to anystring2??????????????
sed 's/\(.*\)1/\12/g'

Remove comments and blank lines:??????????????
sed '/ *#/d; /^ *$/d'

Print 1000th line:
sed -n '1000{p;q}'

sed ':a; /\\$/N; s/\\\n//; ta'    Concatenate lines with trailing \
sed 's/[ \t]*$//'    Remove trailing spaces from lines
sed 's/\([`"$\]\)/\\\1/g'    Escape shell metacharacters active within double quotes
seq 10 | sed "s/^/      /; s/ *\(.\{7,\}\)/\1/"    Right align numbers



sed -n '10,20p;20q'    Print lines 10 to 20
sed -n 's/.*<title>\(.*\)<\/title>.*/\1/ip;T;q'    Extract title from HTML web page
sed -i 42d ~/.ssh/known_hosts    Delete a particular line

Unix - Alt dizin içinde find & replace

Tüm makinada:
find / | xargs grep -l "string1" | xargs sed -i 's/str1/str2/g'

Altdizinlerde:
find . | xargs grep -l "string1" | xargs sed -i 's/str1/str2/g'