I am using a terminal with a white/light background, but output of a command I used contains text with white color (i.e., foreground color = white). Is there any way (e.g., using shell script?) to map all white foreground to black foreground, and keeping the other colors unchanged?
It depends on the terminal. In xterm, you can change the mapping of color numbers to color names with the escape sequence
OSC 4 ; NUMBER ; NAME BEL. Explicit white is color 7, so:
This affects the color whether it's used as a background or foreground. It's a rendering setting, i.e. it affects all output past and future.
Few other terminals support this.
The precise features of your terminal will differ between versions and implementations. Some traditional terminals offer very little by way of individual window customization, while many desktop OSes have spiffy terminals where you can freely adjust the colors of an individual window by opening the preferences.
As a quick and dirty workaround, selecting the text with the mouse often applies a different color palette which might help. If it doesn't, pasting the text into another window where you have the colors you want is usually a small additional step.