I want to pass the output of a command as positional parameter to a script file. I am running the command below:
whois -h 192.168.0.13 google.com | grep -e Domain\ Name
That command will give me a "name". What I want to do is pass that output again to a shell script file as positional parameter.
my-file.sh:
#!/bin/bash
#My First Script
if [ $1 == "my-domain-name" ]; then
echo "It is ok"
exit 1
fi
So, basically what I want to do is something like this:
whois -h 192.168.0.13 google.com | grep -e Domain\ Name | -here pass the Name to my-file.sh and run that file
exit 0if it is OK.[ "$1" = my-domain-name ]. A constant string that has no spaces or wildcard characters doesn't need quotes; a parameter expansion always needs quotes; and==isn't guaranteed to work in[ ]with all shells, whereas=is mandated by the POSIX standard.