Skip to content

Instantly share code, notes, and snippets.

View elee's full-sized avatar

Eric Lee elee

View GitHub Profile
import os
coredir = "/etc/sv/core"
histfile = "/tmp/corehist.txt"
dirlist = os.listdir(coredir)
dirlist.remove("core")
dirlist.count
with open(histfile, 'w') as f:
value_in_file = f.readline()
if os.path.exists('/private/tmp/corehist.txt'):
with open('/private/tmp/corehist.txt', 'r') as f:
int_from_file = int(f.readline())
if my_int != int_from_file:
f.seek(0)
f.writeline(new_int_value)
else:
with open('/private/tmp/corehist.txt', 'w+') as f:
f.write(42)
We couldn’t find that file to show.
use strict;
use warnings;
# output:
# foo
# bar
combine({
name => "foo",
surname => "bar"