<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>trim</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,19 +1,29 @@
 #!/usr/bin/env ruby
 # Start Date: Sunday January 4, 2009
-# Current Version: 0.99
+# Current Version: 1
 # Author: Joseph Pecoraro
 # Contact: joepeck02@gmail.com
 # Decription: Grab certain lines of a file
 # with a simple syntax (see usage). Silent
-# usage useful for piping output.
+# usage useful for piping output and Pipe
+# option for piping input into it
 
 # Wrapper around functionality
 class FileLines
 	
-	attr_accessor :lines
-
-	def initialize(filename, options)
-		@lines = File.readlines(filename)
+	attr_accessor :lines, :stdin
+	
+	def initialize(options, filename=nil)
+		if filename.nil?
+			@stdin = true
+			@lines = []
+			while line = STDIN.gets
+				@lines &lt;&lt; line
+			end
+		else
+			@stdin = false
+			@lines = File.readlines(filename)
+		end
 		@silent = false
 		parse_options(options)
 	end
@@ -27,11 +37,14 @@ class FileLines
 	end
 	
 	def parse(args)
-		puts unless @silent
 		args.each do |arg|
 			
+			# String: all
+			if m = arg.match( /^all$/ )
+				print_lines(0, @lines.size)
+			
 			# Ranges: 3-7
-			if m = arg.match( /^(\d+)-(\d+)$/ )
+			elsif m = arg.match( /^(\d+)-(\d+)$/ )
 				lower = m[1].to_i
 				upper = m[2].to_i
 				lower = 1 if lower.zero? # 0 =&gt; 1
@@ -73,11 +86,11 @@ class FileLines
 				print_line( lineno )
 			end
 
-			puts unless @silent
 		end
 	end
 	
 	def print_lines(lower, upper)
+		return if lower &gt; @lines.size
 		i = lower
 		@lines[lower, upper].each do |line|
 			if @silent
@@ -141,9 +154,12 @@ if $0 == __FILE__
 	# Pull out the Options
 	options = ARGV.select { |arg| arg.match(/-[a-z]/i) }
 	ARGV.delete_if { |arg| arg.match(/-[a-z]/i) }
+	
+	# Special Handling for Pipes (don't require a filename)
+	is_pipe = !STDIN.tty?
 
 	# Check Cmd Line Args and Print Usage if needed
-	if ARGV.size &lt;= 1
+	if ARGV.size &lt;= 1 &amp;&amp; !is_pipe
 		puts &quot;usage: line [options] filename numbers&quot;
 		puts
 		puts &quot; options:&quot;
@@ -155,6 +171,7 @@ if $0 == __FILE__
 		puts &quot;   -1               Prints the last line, (negative)&quot;
 		puts
 		puts &quot; extra formats:&quot;
+		puts &quot;   all              Prints out all lines&quot;
 		puts &quot;   ~5               Prints 2 (default) lines before and after 5&quot;
 		puts &quot;   4~10             Prints 4 lines before and after 10&quot;
 		puts &quot;   *7 or 8*         Prints all lines before or after the number&quot;
@@ -162,14 +179,20 @@ if $0 == __FILE__
 		puts &quot;   2:5/1            Starts at line 2, prints and skips...&quot;
 		puts
 		exit 1
+	end
 		
+	# Pipe Usage
+	if is_pipe
+		FileLines.new(options).parse(ARGV)		
+	
 	# Unreadable File
 	elsif !File.readable?(ARGV[0])
 		puts &quot;line: file '#{ARGV[0]}' did not exist or was unreadable.&quot;
 		exit 1
-	end
 
 	# Run the Program
-	FileLines.new(ARGV[0], options).parse(ARGV[1, ARGV.size])
+	else
+		FileLines.new(options, ARGV[0]).parse(ARGV[1, ARGV.size])
+	end
 
 end</diff>
      <filename>line</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d6ab0ee1b1346a8150d5dbf6c795074f52c7f6b8</id>
    </parent>
  </parents>
  <author>
    <name>Joseph Pecoraro</name>
    <email>joepeck02@gmail.com</email>
  </author>
  <url>http://github.com/JosephPecoraro/scripts/commit/98c2960c15d32385998bc260fee59cd0c97a7d7d</url>
  <id>98c2960c15d32385998bc260fee59cd0c97a7d7d</id>
  <committed-date>2009-04-04T13:46:03-07:00</committed-date>
  <authored-date>2009-04-04T13:46:03-07:00</authored-date>
  <message>Improved line for piped input. Added trim, a special case of line.</message>
  <tree>d81d47e7b6bd364c673c8673d34a4ae4898d1033</tree>
  <committer>
    <name>Joseph Pecoraro</name>
    <email>joepeck02@gmail.com</email>
  </committer>
</commit>
