summaryrefslogtreecommitdiff
path: root/sample/io.rb
blob: c3c1a47b28108ed2bbda0d9447bc4aa672f92be1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# IO test
# usage: ruby io.rb file..

home = getenv("HOME")
home.sub("m", "&&")
print(home, "\n")
print(home.reverse, "\n")

if File.s("io.rb")
  print(File.s("io.rb"), ": io.rb\n")
end

$/="f\n"
for i in "abc\n\ndef\nghi\n"
  print("tt: ", i)
end

printf("%s:(%d)%s\n", $0, $ARGV.length, $ARGV[0])
passwd = open($ARGV[0], "r")
#printf("%s", passwd.find{i|i =~ /\*/})

n = 1
for i in passwd #.grep(/^\*/)
  printf("%6d: %s", n, i)
  n = n + 1;
end

fp = open("|-", "r")

if fp == nil
  for i in 1..5
    print(i, "\n")
  end
else
  for line in fp
    print(line)
  end
end

def printUsage()
  if $USAGE
    apply($USAGE);
  end
end