Skip to main content
added 4 characters in body
Source Link
Stéphane Chazelas
  • 584.6k
  • 96
  • 1.1k
  • 1.7k

From man sh

-c string   If the -c option is present, then commands are read from string. 
            If there are arguments after the string, they are assigned to the
            positional parameters, starting with $0

It means your command should be like this:

 $ sh -c 'echo $0'"$0"' foo 
 foo

Similarly:

$ sh -c 'echo $0"$0 $1'$1"' foo bar
foo bar

That was the first part to understand ,understand; the second case is simple and don'tdoesn't need explanation  , iI guess.

From man sh

-c string   If the -c option is present, then commands are read from string. 
            If there are arguments after the string, they are assigned to the
            positional parameters, starting with $0

It means your command should be like this:

 $ sh -c 'echo $0' foo 
 foo

Similarly:

$ sh -c 'echo $0 $1' foo bar
foo bar

That was the first part to understand , the second case is simple and don't need explanation  , i guess.

From man sh

-c string   If the -c option is present, then commands are read from string. 
            If there are arguments after the string, they are assigned to the
            positional parameters, starting with $0

It means your command should be like this:

 $ sh -c 'echo "$0"' foo 
 foo

Similarly:

$ sh -c 'echo "$0 $1"' foo bar
foo bar

That was the first part to understand; the second case is simple and doesn't need explanation, I guess.

Format man page text to not wrap. Syntax hint none ofr man page text. Add shell prompt to indicate written command.
Source Link

From man sh

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned
             to the positional parameters, starting with $0
-c string   If the -c option is present, then commands are read from string. 
            If there are arguments after the string, they are assigned to the
            positional parameters, starting with $0

It means your command should be like this:

 $ sh -c 'echo $0' foo 
 foo

Similarly:

$ sh -c 'echo $0 $1' foo bar
foo bar

That was the first part to understand , the second case is simple and don't need explanation , i guess.

From man sh

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned
             to the positional parameters, starting with $0

It means your command should be like this:

 sh -c 'echo $0' foo 
 foo

Similarly:

sh -c 'echo $0 $1' foo bar
foo bar

That was the first part to understand , the second case is simple and don't need explanation , i guess.

From man sh

-c string   If the -c option is present, then commands are read from string. 
            If there are arguments after the string, they are assigned to the
            positional parameters, starting with $0

It means your command should be like this:

 $ sh -c 'echo $0' foo 
 foo

Similarly:

$ sh -c 'echo $0 $1' foo bar
foo bar

That was the first part to understand , the second case is simple and don't need explanation , i guess.

deleted 2 characters in body
Source Link
Ijaz Ahmad
  • 7.4k
  • 7
  • 35
  • 46

From man sh

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned
             to the positional parameters, starting with $0

It means your command should be like this:

 sh -c 'echo $0' foo 
 foo

Similarly:

sh -c 'echo $0 $1' foo bar
foo bar

That was the first part to understand , the second case is simple and don't need explanation , i guess.

From man sh

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned
             to the positional parameters, starting with $0

It means your command should be like this:

 sh -c 'echo $0' foo 
 foo

Similarly:

sh -c 'echo $0 $1' foo bar
foo bar

From man sh

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned
             to the positional parameters, starting with $0

It means your command should be like this:

 sh -c 'echo $0' foo 
 foo

Similarly:

sh -c 'echo $0 $1' foo bar
foo bar

That was the first part to understand , the second case is simple and don't need explanation , i guess.

deleted 2 characters in body
Source Link
Ijaz Ahmad
  • 7.4k
  • 7
  • 35
  • 46
Loading
Source Link
Ijaz Ahmad
  • 7.4k
  • 7
  • 35
  • 46
Loading