I have doubts with the following command:
I have doubts in the input arguments value i.e. $0, $1, $2...
Step by step:
1.- % find "$1" -name "*.html" -print0 | ...
where:
- $1 is the name of the directory to search on
2.-
where:
- $0 is sh -c
- $1 is the same as $1 in the step 1 ??? Why???
- $2 is the htmlA
- $3 is the htmlB and so on with $4, $5 etc.
3.- Finally, .. sh "$2" makes a shift
The value in $3 will be now $2
Is my understanding correct? How is the value of $1 taken?
Not sure I understand your doubts, so please correct me should my interpretation be wrong.
Generally, you need to differentiate between positional parameters ($1, $2, ...) of the parent shell, and those that the subshell will see. Whatever you see in you above command line is the parent shell. So -
1.- Yes if the parent shell's first positional parameter holds a starting directory.
2.- the subshell started by sh will have a concoction of parent and sub shell's pos. parameters, depending on where and how you put single and / or double quotes. As this is difficult to tell from here, I'd start with a small subset of the commands and parameters to find out.
3. Definitely NOT. shift ist the (builtin) command to shift positional parameters, sh will run a (bourne) shell as you did it in the xargs parameters.
8.4.2 Invoking the shell from xargs. Normally, xargs will exec the command you specified directly, without invoking a shell. This is normally the behaviour one would want. It's somewhat more efficient and avoids problems with shell metacharacters, for example.
I'd start with a small subset of the commands and parameters to find out.
Can someone give a source to start digging on this?
Furthermore. Can someone clarify the following:
$0 $1 $2 ... After the sh -c
$0: ?????
$1: name of the log file Why ??? From where is taken
$2: htmlA file
$3: htmlB file
...
I am trying to make an interactive script. Only problem my inputs are not read and correctly channeled.
Please help:
Here is my code
#!/bin/sh
PATHSCRIPT=/home/pp/tmp
#if ; then
# echo "Syntax : $0 input off lat sample"
# exit 1
# fi
echo "Choice of Graph"
echo "1 -- Type... (5 Replies)
Hi All,
I am running the script
VBoxManage list vms |sed 's/"//g' | cut -d " " -f1 > har1out.mytxt
result=`cat har1out.mytxt | grep $1'
echo $result
echo $1
{
if
then
echo pass
else
echo fail
fi (2 Replies)
Hello,
Is there any method thorugh which script can take argument if pass otherwise if argument doesn't pass then it takes the argument from the configuration file
i.e I am workiing on a script which will run through crontab and the script will
chekout the code ,zip and copy to the... (3 Replies)
If ($argv == “-debug”) then
Echo “in loop”
Endif
But this is not working. If I modify this code and remove “-“, then it works.
Similarly I am getting problem using grep command also
Grep “-debug” Filename
Can someone please help me on how to resolve these... (1 Reply)
Can someone please help me with this SHELL script?
I need to create a script that gets a positive number n as an argument. The script must calculate the factorial of its argument. In other words, it must calculate n!=1x2x3x...xn. Note that 0!=1.
Here is a start but I have no clue how to... (3 Replies)
Hi,
Lets say I have a script "ss" which does this
read abc
echo $abc
read pqr
echo $pqr
Now if I want to pass and argument to only "abc" how do I do it.
If I do
echo "somevalue" | ss, it does not prompt for pqr and its value comes out as blank.
Any help is appreciated
Thanks
P (6 Replies)
I am trying to extract two fields from the output of ifconfig command on one of my sun server . The output looks like :
root@e08k18:/tmp/test# ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
ce0:... (9 Replies)
Hi,
I have a shell script that has to taken inputs from a file say "Inputs". Now I take 2 inputs at a time. Suppose the Inputs file contains numbers like
2
3
4
5
Now I have a written a script for adding 2 numbers. When I run the script for first time 2 and 3 must be the inputs. When i run the... (4 Replies)
Have tried the search, but nothing resembles what I'd like to accomplish. I am attempting to write a script that will allow the user to input a list of data at the command prompt, then the data is used by another script for processing. I am allowing the user a list of 10 members in order to... (4 Replies)