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

Batch - Dosya ismindeki uzantıyı silmek

@echo off
    for /R "C:\Path" %%f in (*.txt) do (
    echo %%~nf
)
pause

Bash - Dosyanın her satırına string prepend etmek

for /f "tokens=*" %a in (input.txt) do (echo oncul_metin.%a) >> output.txt

13 Kasım 2017 Pazartesi

set a=5
set /a c=%a%*16

10 Kasım 2017 Cuma

Batch - Komut satırı argümanlarını kullanmak

echo off

set arg1=%1
set arg2=%2

echo arguman1: %arg1%
echo arguman2: %arg2%

Batch - Replace

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

Bash - Dosyanın satırlarını döngüye input etmek


while read r; do
        git clone $r
done <repo_list.txt

Git - Repoya commit edenlerin listesi

git shortlog -sn | cut -f2

Bash - Komut çıktısını değişkene atamak

dir=$(pwd)

Bash - Url parse etmek

echo https://repository/COLLECTION/app/_git/repo  | cut -d/ -f7-

Python - Metin içinde stringi sayma

>>> "abcdabcva".count("ab")
2

Python - Metin içinde string arama

if word in mystring:
   print 'success'

Bash - Komut çıktısını döngüye input etmek

while read u; do
  echo kullanici:$u
done < <(git shortlog -sn | cut -f2)

Git - Commit logları

git log --committer="Yigit" --oneline --shortstat --after=2017-01-01 --before=2018-01-01

Sed - Dosyanın her satırına prepend etmek

text.txt | sed "s/^/[prepend1] /"

Python - Kabuk komutu çalıştırmak

import os

os.system('dir')

Python - Kabuk komutunun çıktısını kullanmak

import os
p=os.popen('dir /s/b pom.xml')

while 1:
 line = p.readline()
 if not line: break
 print "Satir:" + line