Concatenar arquivos seguindo uma lista
Boa tarde.
tenho um txt com um texto seguindo o seguinte padrão:
file1.txt;file2.txt
file3.txt;file4.txt
....
Dentro do mesmo diretório, eu tenho os file1.txt, file2.txt., etc..
Quero fazer com que os arquivos presentes em uma mesma linha sejam concatenados em um novo arquivo.
Ex:
file1.txt;file2.txt > file1.txt_file2.txt.concat
onde file1.txt_file2.txt.concat tem o conteúdo concatenado dos 2 arquivos.
se fosse no terminal, seria:
cat file1.txt file2.txt > file1.txt_file2.txt.concat
Sei que é simples, mas não está rolando.
Agradeço o help
até onde cheguei:
#!/usr/bin/ruby
mcl = File.open(ARGV[0]).readlines
mcl.each do |line|
g1 = line.split(';')[0]
g2 = line.split(';')[1]
Kernel.system("cat #{g1} #{g2} > #{g1}#{g2}.concat")
end
Discussão (0)
Carregando comentários...