![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C Shell Script query | bpupdown | Shell Programming and Scripting | 1 | 05-13-2008 07:38 PM |
| shell script related query | gopsman | Shell Programming and Scripting | 1 | 12-03-2007 12:50 AM |
| executing a SQL query in shell script | lijju.mathew | Shell Programming and Scripting | 1 | 05-17-2007 11:29 AM |
| Query on a shell script logic | tipsy | Shell Programming and Scripting | 1 | 06-29-2006 05:38 PM |
| Executing a SQL query from a shell script | 98_1LE | UNIX for Dummies Questions & Answers | 3 | 03-23-2002 03:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Shell script query
Hi,
I am stuck assigning a value to a variable. I am trying to assign a value to a variable but getting error.... IP_ADDR=grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg | cut -d : -f 2| cut -d . -f 1-3| sed s/" "//g I am using this script to grep first three octets of an IP address from a file and assign the value to IP_ADDR....but I am not able to assign the value to the variable... Please some one help. Regards, Abhishek |
|
||||
|
I tried like this after searching for it in the forums....
I=`grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg | cut -d : -f 2 | cut -d . -f 1-3 | sed s/" "//g` But its giving the error as: abhi ts/39:[~] 183) ./abhi./abhi: .cfg: not found ./abhi: -n: not found Exit 1 If I run it on shell its working abhi ts/39:[~] 185) grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg| cut -d : -f 2 | cut -d . -f 1-3 | sed s/" "//g 172.174.158 Please can someone help Regards, Abhi |
|
||||
|
Hi Sank,
Ya it didn't work but thanks anyways... I tried with putting ksh as the shell #! /bin/ksh -p and then using it like this I=$(grep 'I.P. Address' /install/cfgdist/`uname -n`.cfg | cut -d : -f 2 | cut -d . -f 1-3 | sed s/" "//g) and it worked Thanks. Regards, Abhi |
| Sponsored Links | ||
|
|