how to give standard input --stdin by using < symbol,as a plain text(string) in bash script, For example i have stored /etc/passwd file by using redirecting > symbol by the same way i want to give plain text as a input

  • Apart from using <, are you concerned about plain text in any particular way? Your question mentions plain text three times.
    – Kusalananda
    May 8, 2018 at 16:31

2 Answers 2


To redirect from stdin, you don't use < you use |. For example (apologies for the useless use of cat)

cat /some/file | my_program

If your "stored /etc/passwd file" resides in a variable, and you are not tied to /bin/sh, you can use the <<< redirection

my_program <<< "$my_variable"

Exactly as you describe, with the indirection (<) operator:

/path/to/executable < /path/to/inputfile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy