1

I have made a batch script that, among other things, merges our DEV branch to our TEST branch using the following command:

tf merge $/Proj/Dev $/Proj/Test /recursive >nul

This command always triggers the following output:

TF401190: The local workspace [workspace];[name] has 110500 items in it, which exceeds the recommended limit of 100000 items. 
To improve performance, either reduce the number of items in the workspace, or convert the workspace to a server workspace.

I know I can avoid all errors/ouput by adding "2>&1" to the end of the command like so:

tf merge $/Proj/Dev $/Proj/Test /recursive >nul 2>&1

Ideally I would just like to ignore/suppress specifically the TF401190 error. I feel like there has to be a way to do this, even if it means checking the output for a specific token/string before allowing it to print. I'm still very new to the command-line and batch scripts. Any help would be greatly appreciated! Thanks.

NOTE: I'm not interested in addressing a solution for the error itself. This question is only concerned with how to suppress any specific error.

2 Answers 2

1

In the bash shell, you can filter out specific errors like this:

ls /nothere

ls: cannot access /nothere: No such file or directory

To suppress that specific error message:

ls /nothere 2>&1 | grep -v 'No such file'

(error message is suppressed)

Checking if other error messages get through:

ls /root 2>&1 | grep -v 'No such file'
ls: cannot open directory /root: Permission denied

(other error messages get through fine)

Sign up to request clarification or add additional context in comments.

4 Comments

same princip in batch: dir notexistent.bla" 2>&1|find /v "File Not Found
Thank you both for the response. Rudi, unfortunately I need the commands for a batch script, not bash. Stephan, by running a quick test in the command prompt I think your solution is going to work. I am going to try it on my script!
Stephan, your solution works, but I think you have your quotations in the wrong place. I believe it should appear as so: dir notexistent.bla 2>&1|find /v "File Not Found"
@nycfdtd you are right.I noticed it, but the timeframe for an edit was already closed. I guessed, you would figure it out yourself anyway ;)
0

The answer to this question is an extension to Is there a way to redirect ONLY stderr to stdout (not combine the two) so it can be piped to other programs?

You need to redirect stderr and stdout in such a way that only errors are output, and pipe the error messages a FIND or FINDSTR command that filters out the messages you don't want.

tf merge $/Proj/Dev $/Proj/Test /recursive 2>&1 >nul | findstr /b ^
  /c:"TF401190: The local workspace " ^
  /c:"To improve performance, either reduce the number of items in the workspace, or convert the workspace to a server workspace."

I've used line continuation to make the code a bit easier to read.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.