When entering that in the command line it works just fine; however when putting that in a bash script it does not. Here is an example of how I'm getting it (I know echo adds a line break after, but thats not the issue).
What I want is just the IP address, no line breaks before or after, in a variable that I can then insert into my local host file, after some tweaking of adding my desired access domain to it.
Here's my command line:
And here's the relevant portion of the .bashrc file:
---------- Post updated at 11:45 AM ---------- Previous update was at 11:35 AM ----------
And same with your method fubaya; works fine directly on the command line, but doesn't work in .bashrc. Here are my modified examples:
My command line:
My .bashrc:
---------- Post updated at 12:07 PM ---------- Previous update was at 11:45 AM ----------
Got it using backquotes as per
Working version of fubaya's method:
And of Scrutinizer's method:
I'm trying to find a command that will trim the white space off a string.
e.g.
$str = " stuf "
$str = trim ( $str )
echo $str // ouput would just be stuf
Thanks, Mark (4 Replies)
All,
I'm a newbie at shell scripting and regular expressions and I just need to take a file that's arranged like the one below, remove all leading and trailing whitespace and add a line break after each word. I've been able to remove a few spaces using various awk, sed and Perl scripts, but... (7 Replies)
Hi Friends,
Can any one help with this issue:
How to trim spaces for each line at the end,
Like I have a file in this format.
EMP1 SMITH 46373 5 STREET HOWARD 74636
EMP2 JONES 5454 { these are spaces ........}
EMP3 SMITH 46373 5 STREET HOWARD 74636
EMP4 JON 2554 { these are... (1 Reply)
Hello,
I am passing a filename to a script to draw parameters from it. However, I want to use part of the filename as a parameter. The filename is transfer_ccf_3731_10.sh but I only need the 3731_10 part of it.
Is this possible? Any help or suggestions would be appreciated!
Regards,
J. (4 Replies)
Hi All,
I am using trim in my code..
ID_SA_SOURCE="`echo "$data" | cut -c17-34 | tr -s " "`"
ID_SA_DEST="`echo "$data" | cut -c35-52 | tr -s " "`"
echo"$ID_SA_SOURCE";"$ID_SA_DEST";
the output is
0608166896; 3001339; contains one whitespace between the two ..how can i remove that single... (3 Replies)
Hi all,
I've been looking for how to eliminate blank spaces in a variable or strings. I've seen several ways, using sed, awk and even python. One of them is use 'tr' command, but it does not work as I expected: For example:
echo " stuff " | tr -s " "leaves one space ahead and another... (3 Replies)
To trim 3rd field in for all the lines of a file and replace the modified string in that particular field.
For example i have a file called Temp.txt having content
Temp.txt
-----------------
100,234,M1234
400,234,K1734
300,345,T3456
----------------
So the modified file output should... (4 Replies)
FOLKS ,
i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one.
thanks...
Venu (3 Replies)
Hi All,
I have a file named as
FAB1_600015_CONRAD.A0_7XYZ12345.000_LT-SWET.01_LTPA25L_20110622-161429_07_WFR12345_20110622-161429_20110712-125228.data.dis
I want to generate a directory taking only the 7XYZ12345.000_WFR12345
The length and format of the Filename will be the same... (2 Replies)
Discussion started by: asheshrocky
2 Replies
LEARN ABOUT NETBSD
dhcpcd-run-hooks
DHCPCD-RUN-HOOKS(8) BSD System Manager's Manual DHCPCD-RUN-HOOKS(8)NAME
dhcpcd-run-hooks -- DHCP client configuration script
DESCRIPTION
dhcpcd-run-hooks is used by dhcpcd(8) to run any system and user defined hook scripts. System hook scripts are found in
/libexec/dhcpcd-hooks and the user defined hooks are /etc/dhcpcd.enter-hook. and /etc/dhcpcd.exit-hook. The default install supplies hook
scripts for configuring /etc/resolv.conf and the hostname. Your distribution may have included other hook scripts to say configure ntp or
ypbind. A test hook is also supplied that simply echos the dhcp variables to the console from DISCOVER message.
Each time dhcpcd-run-hooks is invoked, $interface is set to the interface that dhcpcd is run on and $reason is to the reason why
dhcpcd-run-hooks was invoked. DHCP information to be configured is held in variables starting with the word new_ and old DHCP information to
be removed is held in variables starting with the word old_. dhcpcd can display the full list of variables it knows how about by using the
-V, --variables argument.
Here's a list of reasons why dhcpcd-run-hooks could be invoked:
PREINIT dhcpcd is starting up and any pre-initialisation should be done.
CARRIER dhcpcd has detected the carrier is up. This is generally just a notification and no action need be taken.
INFORM dhcpcd informed a DHCP server about it's address and obtained other configuration details.
BOUND dhcpcd obtained a new lease from a DHCP server.
RENEW dhcpcd renewed it's lease.
REBIND dhcpcd has rebound to a new DHCP server.
REBOOT dhcpcd successfully requested a lease from a DHCP server.
IPV4LL dhcpcd failed to contact any DHCP servers but did obtain an IPV4LL address.
STATIC dhcpcd has been configured with a static configuration which has not been obtained from a DHCP server.
3RDPARTY dhcpcd is monitoring the interface for a 3rd party to give it an IP address.
TIMEOUT dhcpcd failed to contact any DHCP servers but was able to use an old lease.
EXPIRE dhcpcd's lease or state expired and it failed to obtain a new one.
RELEASE dhcpcd's lease was released back to the DHCP server for re-use.
NAK dhcpcd received a NAK from the DHCP server. This should be treated as EXPIRE.
NOCARRIER dhcpcd lost the carrier. The cable may have been unplugged or association to the wireless point lost.
FAIL dhcpcd failed to operate on the interface. This normally happens when dhcpcd does not support the raw interface, which means
it cannot work as a DHCP or ZeroConf client. Static configuration and DHCP INFORM is still allowed.
STOP dhcpcd stopped running on the interface.
DUMP dhcpcd has been asked to dump the last lease for the interface.
TEST dhcpcd received an OFFER from a DHCP server but will not configure the interface. This is primarily used to test the variables
are filled correctly for the script to process them.
ROUTERADVERT dhcpcd has received an IPv6 Router Advertisment, or one has expired.
FILES
When dhcpcd-run-hooks runs, it loads /etc/dhcpcd.enter-hook and any scripts found in /libexec/dhcpcd-hooks in a lexical order and then
finally /etc/dhcpcd.exit-hook
SEE ALSO dhcpcd(8)AUTHORS
Roy Marples <roy@marples.name>
BUGS
Please report them to
http://roy.marples.name/projects/dhcpcd
SECURITY CONSIDERATIONS
Little validation of DHCP options is done in dhcpcd itself. Instead, it is up to the hooks to handle any validation needed. To this end,
some helper functions are provided, such as valid_domainname as used by the 20-resolv.conf hook to ensure that the hostname is not set to an
invalid value. valid_path is also provided, but is currently unused by a stock hook script.
BSD March 19, 2012 BSD