manuelgu
manuelgu

Reputation: 105

Pseudo-input for Bash's "read" variable

I have a script listening for a user input like that.

read -p "Run? (y/[n]) " -n 1 -r

if [[ $REPLY =~ ^[Yy]$ ]]; then
    [..]
fi

Is there a way (upon executing the script) to already send the value which read is going to read and handle?

Upvotes: 0

Views: 44

Answers (1)

manuelgu
manuelgu

Reputation: 105

your_script.sh <<< "Y"


This also supports multiple read's

your_script.sh <<< "YNYYNNY"

Upvotes: 2

Related Questions