Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-16 09:02:48

0001 #!/usr/bin/env ruby
0002 
0003 # SPDX-License-Identifier: LGPL-3.0-or-later
0004 # Copyright (C) 2023 Christopher Dilks
0005 
0006 # truncate a config file to the specified number of ROOT files
0007 
0008 if ARGV.length < 2
0009   $stderr.puts "USAGE: #{$0} [config_file] [num_files]"
0010   exit 2
0011 end
0012 configN = ARGV[0]
0013 num     = ARGV[1].to_i
0014 
0015 outN = configN + ".truncated"
0016 out = File.open outN, 'w'
0017 cnt = 0
0018 
0019 File.readlines(configN).each do |line|
0020   if line.match? /\.root/
0021     unless line.match? /^[#:]/
0022       cnt += 1
0023     end
0024   end
0025   out.puts line
0026   break if cnt >= num
0027 end
0028 
0029 out.close
0030 system "cat #{outN}"
0031 puts "#{'-'*40}\nwrote #{outN}"