Sponsored Content
Top Forums Shell Programming and Scripting Need bash script to use a sed command as a variable Post 303038031 by Scrutinizer on Thursday 22nd of August 2019 01:53:54 AM
Old 08-22-2019
Note that with standard sed (non-GNU) there needs to be a ; before the trailing }:
Code:
ip=$(sed -n '/inet */{s///p;q;}' config.boot)

or we can avoid the braces by using negation style:
Code:
ip=$(sed '/inet */!d; s///; q' config.boot)

--
Alternatively we can avoid the sub shell / external command altogether with just standard shell:
Code:
until [ "$inet" = inet ]; do
  read inet ip
done < config.boot

--
Note also that these are all naive approaches without knowing what the format of config.boot looks like. Also, if the are more inet configs in the same file, these will only pick the first one indiscriminately.

Last edited by Scrutinizer; 08-22-2019 at 03:16 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

BASH -- sed -- variable

Hi, I'm new at bash scripting -- can anyone here help me about the sed command? I need to be able to edit and or delete a text from an outside file ie file.txt -- I'm passing a variable and not a string I was thinking of something like echo -n "What do you want to edit?: " read edit sed... (1 Reply)
Discussion started by: Imajean
1 Replies

2. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

3. Shell Programming and Scripting

Special characters in a bash variable in sed

Hello, I am trying the following: echo __CHANGEME__ >> testfile VAR1="&&&" sed -i "s|__CHANGEME__|${VAR1}|" testfile cat testfile This results in testfile containing __CHANGEME____CHANGEME____CHANGEME__ Whereas I want it to result in &&& I understand that if VAR1="\&\&\&" then... (3 Replies)
Discussion started by: linuxnewbeee
3 Replies

4. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

5. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

6. Shell Programming and Scripting

bash variable (set via awk+sed) not working as expected

Hi! Been working on a script and I've been having a problem. I've finally narrowed it down to this variable I'm setting: servername=$(awk -v FS=\/ '{ print $7 } blah.txt | sed 's\/./-/g' | awk -v FS=\- '{print $1}')" This will essentially pare down a line like this: ... (7 Replies)
Discussion started by: creativedynamo
7 Replies

7. Shell Programming and Scripting

In bash script, how to assign output of a command to a variable while keeping tabs?

Hi, wondering if it's been asked before but didn't find matches from google. Basically I have this line: myvar=$(echo -e "a\tb") Now somehow the '\t' from the echo output gets replaced with white space and then stored in $myvar. It creates a problem for me later to use tab as delimiter to do... (2 Replies)
Discussion started by: birddie
2 Replies

8. Shell Programming and Scripting

Bash script set command to a variable

Hi, Will following set up work in bash script? I've got errors if assigning following binary command to a variable. But on the other hand, COMMAND="ls" works. Any explanation please? How can I assign binary command to a variable COMMAND then I can just call ${COMMAND}? COMMAND="rsync"... (3 Replies)
Discussion started by: hce
3 Replies

9. Shell Programming and Scripting

sed command not accepting variable in shell script

I am using a shell script in fedora linux. While calling to the shell I am also passing an argument (var1=0.77) like shown below sh gossip.sh var1=0.77 in the shell following command is written (which doesn't work) sed - i -e 's@prob=@prob="$var1";//@g' file.txt Actually i want the... (7 Replies)
Discussion started by: Fakhar Hassan
7 Replies

10. Shell Programming and Scripting

Executing sed command inside a bash script

I want to run commands inside a bash script. An example is I want to pass the command in a string as regexp as an argument to the script, then run sed on the bash variable sed.sh regexp sed.sh "-i \"s/<p>//g\"" then call sed "$regexp" $fl (3 Replies)
Discussion started by: Kangol
3 Replies
in.iked(1M)						  System Administration Commands					       in.iked(1M)

NAME
in.iked - daemon for the Internet Key Exchange (IKE) SYNOPSIS
/usr/lib/inet/in.iked [-d] [-f filename] [-p level] /usr/lib/inet/in.iked -c [-f filename] DESCRIPTION
in.iked performs automated key management for IPsec using the Internet Key Exchange (IKE) protocol. in.iked implements the following: o IKE authentication with either pre-shared keys, DSS signatures, RSA signatures, or RSA encryption. o Diffie-Hellman key derivation using either 768, 1024, or 1536-bit public key moduli. o Authentication protection with cipher choices of DES, Blowfish, or 3DES, and hash choices of either HMAC-MD5 or HMAC-SHA-1. Encryption in in.iked is limited to the IKE authentication and key exchange. See ipsecesp(7P) for information regarding IPsec protection choices. in.iked starts at boot time if the /etc/inet/ike/config file exists. See ike.config(4) for the format of this file. in.iked listens for incoming IKE requests from the network and for requests for outbound traffic using the PF_KEY socket. See pf_key(7P). in.iked has two support programs that are used for IKE administration and diagnosis: ikeadm(1M) and ikecert(1M). The SIGHUP signal causes the IKE daemon to read /etc/inet/ike/config and reload the certificate database. SIGHUP is equivalent to using ikeadm(1M) to read the /etc/inet/ike/config file as a rule, for example: example# ikeadm read rule /etc/inet/ike/config OPTIONS
The following options are supported: -c Check the syntax of a configuration file. -d Use debug mode. The process stays attached to the controlling terminal and produces large amounts of debugging output. -f filename Use filename instead of /etc/inet/ike/config. See ike.config(4) for the format of this file. -p level Specify privilege level (level). This option sets how much ikeadm(1M) invocations can change or observe about the running in.iked. Valid levels are: 0 Base level 1 Access to preshared key info 2 Access to keying material If -p is not specified, level defaults to 0. SECURITY
This program has sensitive private keying information in its image. Care should be taken with any core dumps or system dumps of a running in.iked daemon, as these files contain sensitive keying information. Use the coreadm(1M) command to limit any corefiles produced by in.iked. FILES
/etc/inet/ike/config /etc/inet/secret/ike.privatekeys/* Private keys. A private key must have a matching public-key certificate with the same filename in /etc/inet/ike/publickeys/. /etc/inet/ike/publickeys/* Public-key certificates. The names are only important with regard to matching private key names. /etc/inet/ike/crls/* Public key certificate revocation lists. /etc/inet/secret/ike.preshared IKE pre-shared secrets for Phase I authentication. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
coreadm(1M), ikeadm(1M), ikecert(1M), ike.config(4), attributes(5), ipsecesp(7P) Harkins, Dan and Carrel, Dave. RFC 2409, Internet Key Exchange (IKE). Network Working Group. November 1998. Maughan, Douglas, Schertler, M., Schneider, M., Turner, J. RFC 2408, Internet Security Association and Key Management Protocol (ISAKMP). Network Working Group. November 1998. Piper, Derrell, RFC 2407, The Internet IP Security Domain of Interpretation for ISAKMP. Network Working Group. November 1998. SunOS 5.10 11 Jun 2003 in.iked(1M)
All times are GMT -4. The time now is 11:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy