Skip to content

Instantly share code, notes, and snippets.

@necmettin
Created January 25, 2023 09:58
Show Gist options
  • Save necmettin/e12bc55822ac9c1e6cf7a04c8c969d34 to your computer and use it in GitHub Desktop.
Save necmettin/e12bc55822ac9c1e6cf7a04c8c969d34 to your computer and use it in GitHub Desktop.
#/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