Created
January 25, 2023 09:58
-
-
Save necmettin/e12bc55822ac9c1e6cf7a04c8c969d34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python3 | |
import sys | |
if len(sys.argv) < 4: | |
print("Dosya adi, bastan kesilecek satir sayisi ve sondan kesilecek satir sayisi ver") | |
if len(sys.argv) < 2: | |
sys.exit() | |
srcfn = sys.argv[1] | |
dstfn = srcfn + ".next" | |
fromstart = int(sys.argv[2]) | |
fromend = int(sys.argv[3]) | |
linecount = 0 | |
with open(srcfn, "r") as f: | |
for line in f: | |
linecount += 1 | |
fromend = linecount - fromend | |
print(f"mevcut satir sayisi: {linecount}") | |
if len(sys.argv) > 2: | |
src = open(srcfn, "r") | |
dst = open(dstfn, "w") | |
counter = 0 | |
for line in src: | |
counter += 1 | |
if counter > fromstart and counter < fromend: | |
dst.write(line) | |
src.close() | |
dst.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment