Saturday, March 12, 2022

[SOLVED] How to takes bash script input from both pipe

Issue

I want to take my script input from both conditions. And also all conditions support to loop.

How can i do that in bash :)

Condition : 1

cat text.txt | ./myscript.sh

Hello
Hello1
Hello2

Condition :2

./myscript.sh single-word

single-word

Solution

If you only have 1 parameter:

#!/bin/bash
#
printf "$(cat $1)\n"


Answered By - Juranir Santos
Answer Checked By - Mary Flores (WPSolving Volunteer)