eccentric filenames 
Author Message
 eccentric filenames


I can't seem to get around this little problem.  I have an array with "test
#01.txt", and "test #02.txt".  These strings represent filenames.  I want
to use these filenames for a command to be passed to be executed via
system(), for example, to cat these two files into a third file named "test

I tried the following:
#!/usr/bin/env ruby

class Array
  def dump
    collect { |i|

arry = ["test #01.txt", "test #02.txt"]

system ("cat #{arry.dump.join(" ")} > \"test #02.txt\"")

Can someone offer an elegant solution?


Wed, 10 Nov 2004 14:23:28 GMT  
 eccentric filenames


> system ("cat #{arry.dump.join(" ")} > \"test #02.txt\"")

For most filenames, shouldn't it suffice to wrap them in quotationmarks
in the string sent to system? I'm not too used to dump.

system ("cat \"#{arry.join('" "')}\" > \"test\ #03.txt\"") # no dump

> Can someone offer an elegant solution?

Not me.

(\[ Kent Dahl ]/)_    _~_    __[ ]___/~
 ))\_student_/((  \__d L b__/  NTNU - graduate engineering - 4. year  )
( \__\_?|?_/__/ ) _)Industrial economics and technological management(
 \____/_?_\____/ (____engineering.discipline_=_Computer::Technology___)

Wed, 10 Nov 2004 18:14:37 GMT  
 eccentric filenames

> arry = ["test #01.txt", "test #02.txt"]

> system ("cat #{arry.dump.join(" ")} > \"test #02.txt\"")
> Can someone offer an elegant solution?

system("cat >#{target}", *files)


The sheep died in the wool.

Wed, 10 Nov 2004 20:16:55 GMT  
 eccentric filenames

At Sat, 25 May 2002 15:57:20 +0900,


> arry = ["test #01.txt", "test #02.txt"]

> system ("cat #{arry.dump.join(" ")} > \"test #02.txt\"")

The redirect clobbers "test #02.txt" before cat.

  content = arry.each {|file| open(file) {|file|}}.join
  open("test #02.txt", "w") {|file| file.write(content)}

Nobu Nakada

Thu, 11 Nov 2004 21:03:27 GMT  
 [ 4 post ] 

 Relevant Pages 

1. How to Specify Variable FileName(!FileName)In Report

2. Using variable filename(!FILENAME)

3. Long Filenames okay for physical filenames???

4. REQUIRES filename (NEEDS filename)

5. DOS 8.3 filenames (how to remove long filenames header)

6. Library os.path.isfile(filename) - long filenames error.

7. Adding PC Filename Extensions to Macintosh Filenames

8. LOGO-L> Two eccentric spheres in UCBLogo & MSWLogo

9. Urgent Help on Deleting a filename using tcl (script) in an application (without using rm filename (in unix))

10. argv filename for J7

11. Need advice on ObjectStudio: Filename length restrictions??

12. Filename named


Powered by phpBB® Forum Software