Sponsored Content
Top Forums Shell Programming and Scripting setting variable value to dynamic sed match - escaping hell Post 302468946 by methyl on Thursday 4th of November 2010 09:03:22 AM
Old 11-04-2010
Just for interest, we can do this without "eval".
Code:
VAR_MATCH=$(set | grep \^"${VAR_NAME}=${VAR_REGEXP}")

We must not have a "^" at the start of $2 for this to work.
 

10 More Discussions You Might Find Interesting

1. IP Networking

Setting up BIND with dynamic IP

I'm a UNIX newbie, so I know I'll be making foolish errors here... I'm trying to set up my Mac OS X 10.2 server to serve my domain name. I've got Apache running reasonably well , and I know Sendmail is up and running... Now, I seem to need to get BIND running for the domain name, and it... (2 Replies)
Discussion started by: caphector
2 Replies

2. UNIX for Advanced & Expert Users

dynamic match thru awk

hey , my i/p text looks like this, FILE_TYPE=01|FILE_DESC=Periodic|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=B FILE_TYPE=02|FILE_DESC=NCTO|FILE_SCHDL_TYPE=Daily|FILE_SCHDL=|FILE_SCHDL_TIME=9:00am|RESULTS=M NOTE Look carefully for the position FILE_TYPE,FILE_DESC... (23 Replies)
Discussion started by: manas_ranjan
23 Replies

3. UNIX for Dummies Questions & Answers

Escaping non-readable characters using grep, sed or awk

I'm trying to parse out DNS logs from dozens of different domain controllers over a large period of time. The logs are rolled up into individual text files by size, which may contain only a portion of a day's activity or several day's worth (depending on amount of activity). I'm splitting them by... (4 Replies)
Discussion started by: seanwpaul
4 Replies

4. UNIX for Dummies Questions & Answers

Escaping " and ' in sed

Okay, I have looked through everything and cant find it... I need to append a line to the end of a a file: I can do it like this: sed '$ a\additional line' -i file.txt However, the extra line I need has both " and ' in it: ie, "additional" line's has to be added. sed '$... (2 Replies)
Discussion started by: imrikk
2 Replies

5. Shell Programming and Scripting

Delete line with match and previous line quoting/escaping problem

Hi folks, I've list of LDAP records in this format: cat cmmac.export.tmp2 dn: deviceId=0a92746a54tbmd34b05758900131136a506,ou=devices,ou=customer,ou=nl,o=upc cmmac: 00:13:11:36:a5:06 dn: deviceId=0a92746a62pbms4662299650015961cfa23,ou=devices,ou=customer,ou=nl,o=upc cmmac:... (4 Replies)
Discussion started by: tomas.polak
4 Replies

6. Shell Programming and Scripting

Escaping backslash and asterisk in egrep to match "\*"

So far what i've got is egrep '^(\\)\*$'No luck. I've searched the web and not much luck. I know about the escape character \ but its confusing to figure out how to use it to match a backslash and use it to escape the asterisk also. Any ides? Thanks! (8 Replies)
Discussion started by: matthewfs
8 Replies

7. Shell Programming and Scripting

Sed:- Supported variable replacement after string match?

Hi All, I am trying to replace the variable in the file after the particular match string. It is being replaced if i hardcode the value and with use of "&" with sed. sed -e "s/URL./& http:\\localhost:7223/g" But when am trying to pass the variable it is failing. I tried multiple... (9 Replies)
Discussion started by: sharsour
9 Replies

8. Shell Programming and Scripting

'Dynamic' setting of variables in bash script

Hi all, I want to dynamically set variables in a bash script. I made a naive attempt in a while loop that hopefully can clarify the idea. n=0; echo "$lst" | while read p; do n=$(($n+1)); p"$n"="$p"; done The error message is: bash: p1=line1: command not found bash: p2=line2: command... (8 Replies)
Discussion started by: jeppe83
8 Replies

9. Shell Programming and Scripting

sed - replacement file path with variable - Escaping / character

Hi,, I have the line below in a file: $!VarSet |LFDSFN1| = '"E:\APC\Trials\20140705_427_Prototype Trial\Data\T4_20140705_Trial_Cycle_Data_13_T_Norm.txt" "VERSION=100 FILEEXT=\"*.txt\" FILEDESC=\"General Text\" "+""+"TITLE{SEARCH=NONE NAME=\"New Dataset\" LINE=1I want to write a script to change... (2 Replies)
Discussion started by: carlr
2 Replies

10. UNIX for Beginners Questions & Answers

Escaping a variable in ksh

I am trying to echo a variable exactly to a script- echo "${var1} ${var2} >> output.output Gives me a blank file. I would like output.output to basically say: ${var1} ${var2} I think I need to use a special escape character for variables. Am I right in assuming that, and is it the... (8 Replies)
Discussion started by: jeffs42885
8 Replies
aoe-mkdevs(8)						      System Manager's Manual						     aoe-mkdevs(8)

NAME
aoe-mkdevs - create special device files for aoe driver SYNOPSIS
aoe-mkdevs {device-dir} env n_partitions=1 aoe-mkdevs {device-dir} DESCRIPTION
The aoe-mkdevs command is deprecated in favor of udev. Systems with udev do not need to use the aoe-mkdevs or aoe-mkself commands, because udev will create device nodes as needed. Systems without udev use aoe-mkdevs to create the character special files necessary to control the aoe driver. The aoe-mkdevs command uses aoe-mkshelf to also create block special files. The aoe drivers after version 49 support dynamic minor device numbers so that a greater number of devices can be supported. The aoe-mkdevs command is incompatible with dynamic device numbers. If your system lacks udev, and you are using an aoe driver version 50 or above, use the aoe_dyndevs=0 module option to force the aoe driver to use static device numbers. If you are not using dynamic device numbers, and you built your aoe driver to support only one partition per device (whole-disk parti- tions), then the device files must match, and you should use the n_partitions environment variable described below. Arguments device-dir This should be the name of the directory where the special device files will be created. ENVIRONMENT VARIABLES
If the n_partitions variable is set in the environment, it will override the default number of partitions per aoe disk, namely 16. EXAMPLE
In this example, the root user on a host named nai creates special files for using the aoe disks in shelf 7. After remembering that the driver doesn't have partition support, this sysadmin gets rid of the mismatching device nodes and calls aoe-mkdevs again with n_partitions set to 1. nai:~# rm -rf /dev/etherd nai:~# aoe-mkdevs /dev/etherd nai:~# ls /dev/etherd | wc -l 1603 nai:~# rm -rf /dev/etherd nai:~# n_partitions=1 aoe-mkdevs /dev/etherd nai:~# ls /dev/etherd | wc -l 103 SEE ALSO
aoe-discover(8), aoe-interfaces(8), aoe-mkshelf(8), aoe-stat(8), aoetools(8), udev(7). AUTHOR
Ed L. Cashin (ecashin@coraid.com) aoe-mkdevs(8)
All times are GMT -4. The time now is 05:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy