//
// reversor.js
//
// Reverses order of lines in a file
//
// Execute on Windows as:
// cscript reversor.js input.txt > output.txt
// ------------------------------------------------
var args = WScript.Arguments;
if(args.length != 1)
WScript.Quit();
// don't use square brackets below...
// args is not an array/dictionary
var in_file = args(0);
var f;
var lines = new Array();
var fso = new ActiveXObject("Scripting.FileSystemObject");
var i = 0;
var fin = fso.OpenTextFile(in_file);
while(!fin.AtEndOfStream)
lines[i++] = fin.ReadLine();
for(i = lines.length - 1; i >= 0; --i)
WScript.StdOut.WriteLine(lines[i]);
fin.Close();
Wednesday, July 28, 2010
Reversing the Order of Lines in a File
Subscribe to:
Post Comments (Atom)
About Me
- Agnel CJ Kurian
- C/C++ Programmer doing CAD on Windows. Some web development experience. Bangalorean.
Blog Archive
Labels
- .net (11)
- advocacy (1)
- apache (2)
- code (1)
- direct3d (1)
- drawing (1)
- geometry (1)
- graphics (1)
- humour (1)
- javascript (1)
- links (1)
- microsoft (1)
- morons (1)
- postgresql (1)
- programming (4)
- python (1)
- rant (5)
- software (1)
- subversion (2)
- svn (1)
- tools (11)
- trac (1)
- truecrypt (1)
- typing (1)
- vc++ (14)
- video (1)
- vs2008 (1)
- windows-forms (1)
- windows7 (1)
No comments:
Post a Comment