Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Inputs argument for sh -c

Shell Programming and Scripting


Tags
bash, dash

Reply    
 
Thread Tools Search this Thread Display Modes
    #8  
Old Unix and Linux 12-07-2017   -   Original Discussion by puertas12
puertas12's Unix or Linux Image
puertas12 puertas12 is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 17 April 2018, 9:54 AM EDT
Posts: 8
Thanks: 1
Thanked 2 Times in 2 Posts
Basically "sh -s" and "sh -c" do the opposite:
  • With sh -s, commands are read from the std input arguments are passed after the sh -s
  • With sh -c, arguments are read from the std input and commands are passed after the sh -c
Is my understanding correct?
Sponsored Links
    #9  
Old Unix and Linux 12-07-2017   -   Original Discussion by puertas12
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 19 April 2018, 5:37 PM EDT
Location: Saskatchewan
Posts: 22,635
Thanks: 1,172
Thanked 4,306 Times in 3,972 Posts
sh -c does not take arguments from standard input, it does not take arguments at all. It takes the script from an argument.
Sponsored Links
    #10  
Old Unix and Linux 12-14-2017   -   Original Discussion by puertas12
puertas12's Unix or Linux Image
puertas12 puertas12 is offline
Registered User
 
Join Date: Oct 2017
Last Activity: 17 April 2018, 9:54 AM EDT
Posts: 8
Thanks: 1
Thanked 2 Times in 2 Posts
Quote:
it does not take arguments at all
What do you mean? $0, $1.. are set to a value according to what is executed in the previous command before pipe ? isn't it?
    #11  
Old Unix and Linux 12-14-2017   -   Original Discussion by puertas12
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 19 April 2018, 5:37 PM EDT
Location: Saskatchewan
Posts: 22,635
Thanks: 1,172
Thanked 4,306 Times in 3,972 Posts
No, they're not. I don't think that code ever worked.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error:--test: argument expected--Even though i give an argument. harsha85 UNIX for Advanced & Expert Users 2 02-20-2012 11:19 PM
Cannot compare argument in if statement in csh/grep command if argument starts with “-“ sarbjit Shell Programming and Scripting 1 02-21-2011 12:23 AM
get positive number n as argument script must calculate the factorial of its argument I-1 Shell Programming and Scripting 3 04-28-2009 09:24 AM
passing argument to shell script that reads user inputs patjones Shell Programming and Scripting 6 04-10-2009 05:42 PM
How to find the last argument in a argument line? nehagupta2008 UNIX for Dummies Questions & Answers 4 06-20-2008 11:05 AM



All times are GMT -4. The time now is 01:11 AM.