Created
September 2, 2015 07:00
-
-
Save shifumin/a003e33101c7537ef456 to your computer and use it in GitHub Desktop.
ファイルの文字列をソートし直しててファイルに出力するRubyスクリプト
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
# -*- coding: utf-8 -*- | |
input_file = ARGV[0] | |
added_filename = '_in_line' | |
# 入力ファイルネームが'hoge.txt'なら出力ファイルネームは'hoge_in_line.txt'とする | |
output_file = File.basename(input_file, '.*') + added_filename + File.extname(input_file) | |
File.open input_file do |i_file| | |
File.open output_file, 'w' do |o_file| | |
o_file.puts i_file.read.split(/\s+/).sort | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment