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
This is a test file. | |
There are many like it. | |
But this test file is mine. |
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
Displaying contents of files | |
% less filename.txt - writes the contents of a file onto the screen a page at a time | |
- Press the [space-bar] if you want to see another page | |
% head filename.txt - writes the first ten lines of a file to the screen. | |
% head -5 filename.txt - write the first five lines. The number 5 can be changed to display the desired number of lines. | |
% less filename.txt - displays the last 15 lines of a file | |
% grep - Searches file for pattern or word |
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 ruby | |
require 'yaml' | |
# Reading file from command line input and declaration of variables | |
stu_info = YAML.load(File.read(ARGV[0])) | |
flag = false | |
keyarr = [] | |
valuearr = [] | |
wholevalue = [] |
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 ruby | |
require 'yaml' | |
# Only runs if and argument is provided at the command prompt | |
if ARGV[0] | |
file = File.open(ARGV[0], 'r') | |
linelist = [] | |
keyarr = [] | |
valuearr = [] | |
flag = false |
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
# Shortest FizzBuzz | |
def fizzbuzz(size) | |
1.upto size do |num| | |
yield num % 15 == 0 ? 'FizzBuzz' : num % 5 == 0 ? 'Buzz' : num % 3 == 0 ? 'Fizz' : num.to_s | |
end | |
end |