Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

DO /P?

May
12,846
164
1. There is no link from "DO /P" (at the top of DO's help) to the explanation at the bottom.

2. I figured the opening '(' of DO's command would signal the end of DO's control arguments. So I was surprised at:
Code:
c:\users\vefatica\desktop> do l in /P grep aablock inbound.txt | cut -f1 ( echo %@word["/",1,%l] )
cut: fatal error: Can not open file '('
Usage : DO [n | FOREVER]

Double-quoting "grep ... | cut -f1" doesn't work. Back-quoting it works, as well as escaping the '|'. Is there a correct way?
 
1. There is no link from "DO /P" (at the top of DO's help) to the explanation at the bottom.

There is a link, and it works fine here.

2. I figured the opening '(' of DO's command would signal the end of DO's control arguments. So I was surprised at:
Code:
c:\users\vefatica\desktop> do l in /P grep aablock inbound.txt | cut -f1 ( echo %@word["/",1,%l] )
cut: fatal error: Can not open file '('
Usage : DO [n | FOREVER]

Double-quoting "grep ... | cut -f1" doesn't work. Back-quoting it works, as well as escaping the '|'. Is there a correct way?

The opening '(' isn't in DO, nor is it even in the same session as DO. "Cut" has been started in a child pipe session, and it has been passed the remainder of the command line ("-f1 ( echo %@word["/",1,%l] )") -- and I think it's unlikely that CUT is going to be able to understand any of that. It certainly isn't going to be able to process the DO argument or the variable function.

You should either group the grep / cut block:

do l in /P (grep aablock inbound.txt | cut -f1) ( echo %@word["/",1,%l] )

or use back quoting. Either will work. (As will escaping the pipe, though that's a little less clear to someone reading the line.)
 
1. Here, the word "DO" (... /P) is blue, but it's not underlined and clicking it does nothing.
 
Not here.
upload_2016-7-3_12-47-37.png
 
Back
Top