LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what does | bash -s do? any example? (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-%7C-bash-s-do-any-example-4175543944/)

fawcaz 05-29-2015 07:33 AM

what does | bash -s do? any example?
 
I am trying to understand what | bash -s does

$ echo ls| bash -s sdfdsf <--- seems to be same as $echo ls |bash . What is the -s asdf doing?

rknichols 05-29-2015 09:31 AM

Te "-s" tells bash to read a command from stdin even though more arguments follow. The "sdfsdf" will be a positional argument to bash, but the command you are passing does not make use of it. Try this:
Code:

echo 'ls $*' | bash -s sdfsdf
Be sure to use single quotes so that the "$*" is passed literally rather than being expanded (probably to nothing) in the echo command.


All times are GMT -5. The time now is 03:31 AM.