Text Wrapping and Redirection in a DOS Window - TechRepublic
Question
May 11, 2009 at 07:04 AM

Text Wrapping and Redirection in a DOS Window

by . Updated 17 years, 1 month ago

Now I know this is just a minor annoyance, but I was wondering if anyone had an explanation for the following behavior, or if possible, a solution.

My DOS window is 200 columns wide. The following command uses all 200 columns of the window:

C:\>dir /w

But when I pipe the output to any other program – more (yes, I know about /p. That’s not the point.), find, findstr, etc. – or when I redirect the output to a file, text wrapping takes place at column 80.

If you’re wondering why I’m asking, below is a batch file called ls.cmd, which aliases ‘ls’ to a big hairy DIR command. I wanted the output to be stripped of everything except the files and directories, so I piped DIR through FINDSTR to remove all the junk. But the last 120 empty columns of output just drive me nuts. Jed (in the cube beside me) says I need to ‘just let it go,’ but I’m sure you know how that goes. Any ideas?

File: ls.cmd
@echo off
dir /ogne/w “%~1” | findstr /v “^.Volume.in.drive. ^.Volume.Serial.Number. ^.Directory.of. ^.*[0-9,].*File(s).*[0-9,].bytes$ ^.*[0-9,].*Dir(s).*[0-9,].bytes.free$ ^$”

This discussion is locked

All Comments