Question

I am trying to write a simple shell script to apply letter replacements to a string, and I am unable to apply several in a row.

The following is the simplest example that I cannot get to work:

#!/bin/bash
tr a b |  tr b c

Now, if I run this script and enter 'a', there is no output.

Was it helpful?

Solution

The pipe won't flow until end of data is detected. Try typing 'a' [enter] ctrl-D or use the following:

echo a | tr a b | tr b c
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top