A lab on reversing a string in Bash using a cli
For this project you will create a command-line tool that reverses a string
- Run the script
./palindromes.sh
to print a common list of palindromes (words that are the same backwards and forward). - Now run them through a string reversal command:
./palindromes.sh | rev
- Run the script
./reverse
with a few words to reverse them:./reverse.sh foo bar biz
- What happened?
- Modify the print statement slightly to use a ":" instead of a "-" in the output.
- Run the following command:
./palindromes.sh | xargs ./reverse.sh
- Explain the output result and why
xargs
was necessary to achieve it.