2

If I want to run the command

md5deep -rb . | find /I ".jpg" | sort > local.md5

and I run it from the command prompt, it shows exactly like how I typed, but when I put it in a .bat file and run that, this is what I see:

md5deep -rb .   | find /I ".jpg"   | sort  1>local.md5

It seems that it inserts tabs before | and it turns > into a 1>. Why? First I thought that it's something to do with the encoding, but the file is just a simple ANSI file.

Does it have anything to do with @@ turning @ inside .bat files?

2 Answers 2

4

It's nothing to worry about. It's just the way the Windows CMD parser outputs the lines when you don't suppress the "trace" output using:

@echo off

or

@commandname

I'm not sure what you're referring to regarding @@ versus @ (except for possibly the above). I don't know of anything special about @@, unless you're confusing it with %% versus % for variable names.

2
  • Sorry, my bad, I was thinking about %% with %. So its nothing to worry about, I can just use the same command as I would on a command line? Thanks!
    – hyperknot
    Mar 21, 2011 at 2:41
  • +1. Indeed, cmd is just clarifying here (especially the 1> part). The statements are identical.
    – Joey
    Mar 21, 2011 at 10:00
1

The 1> refers to how standard out is being redirected within the bat file.

You have two channels, one for standard out (1>), and one for standard error out (2>). They use either 1> or 2> for processing, and provide two different types of execution feedback. I have this list for different redirection permutations:

command > file      Write standard output of command to file
command 1> file     Write standard output of command to file (same as previous)
command 2> file     Write standard error of command to file (OS/2 and NT)
command > file 2>&1     Write both standard output and standard error of command to file (OS/2 and NT)
command >> file     Append standard output of command to file
command 1>> file    Append standard output of command to file (same as previous)
command 2>> file    Append standard error of command to file (OS/2 and NT)
command >> file 2>&1    Append both standard output and standard error of command to file (OS/2 and NT)
commandA | commandB     Redirect standard output of commandA to standard input of commandB
commandA 2>&1 | commandB    Redirect standard output and standard error of commandA to standard input of commandB (OS/2 and NT)
command < file  command gets standard input from file
command 2>&1    command's standard error is redirected to standard output (OS/2 and NT)
command 1>&2    command's standard output is redirected to standard error (OS/2 and NT)

This is from Rob van der Woude's excellent web site on Win32 scripting: http://www.robvanderwoude.com/redirection.php

Rob

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .