root@localhost# echo 'server $serviceName -connectorType $connectorType -ipAddress $ipAddress -port $port -domain $domain' | cut -d "-" -f 1
O/P= server $serviceName
when i grep the o/p -v nothing is displayed
now how to output the all data by excluding the O/P (server $serviceName) from the data which i entered in the echo command.
the o/p should look like
-connectorType $connectorType -ipAddress $ipAddress -port $port -domain $domain
zaxxon
July 27, 2011, 5:09am
2
... | sed 's/server $serviceName//'
aigles
July 27, 2011, 5:18am
3
echo 'server $serviceName -connectorType $connectorType -ipAddress $ipAddress -port $port -domain $domain' | sed 's/^[^-]*//'
Jean-Pierre.
Thanks aigles and zaxxon. its works fine.
i had a samall doubt what does the char ^ in sed command mean sed 's/^[^-]*//'
kalyankalyan:
root@localhost# echo 'server $serviceName -connectorType $connectorType -ipAddress $ipAddress -port $port -domain $domain' | cut -d "-" -f 1
the o/p should look like
-connectorType $connectorType -ipAddress $ipAddress -port $port -domain $domain
Or try as
echo 'server $serviceName -connectorType $connectorType -ipAddress $ipAddress -port $port -domain $domain' | cut -d " " -f3-
panyam
July 27, 2011, 6:09am
6
^ -- begining of line
[^] -- negate the meaning.
So [^-] -- except "-" if any thing else comes
An example better expalins:
SCRIPTS>cat input_file
-dsdsd
ds-dsds
avalon:/disk3/upat/SCRIPTS>sed 's/^[^-]*//' input_file
-dsdsd
-dsds