Sponsored Content
Full Discussion: Using sed to replace string
Top Forums Shell Programming and Scripting Using sed to replace string Post 302987082 by oferg on Monday 5th of December 2016 02:17:46 AM
Old 12-05-2016
Using sed to replace string

Hello guys,
I'm working in a cellular company and i'm trying to do a script to run some commands automaticlly.
I'm using Solaris version :SunOS pk-ercuas4 5.10 in my work. I've a file that creates by script named test1.mos that that look like:

Code:
confb+
gsg+

lt all

$date = `date +%d%m%y_%H%M`

l+ /home/yesumim/LTE_INT/LTE8282_2546_2547/10_Const_$nodename_$date.log

$RbsType = readinput(pls input RbsType eg RBS6601,:)
$hubPosition = readinput(pls input hubPosition eg A7,:)
$Is_Stand_Alon = readinput(pls input Is_Stand_Alon y/n,:)
.
.
.
.
l-

confb-
gs-


in this test.mos file i want to edit in place the 3 following lines:

Code:
 $RbsType = readinput(pls input RbsType eg RBS6601,:)
 $hubPosition = readinput(pls input hubPosition eg A7,:)
 $Is_Stand_Alon = readinput(pls input Is_Stand_Alon y/n,:)

i want to put instad 3 variables i'm asking from the user before and replace them with this 3 lines to look like:

Code:
$RbsType = ofer 
$hubPosition = Genadi
$Is_Stand_Alon = Ido

The first two lines I succedded to replace but in the third row I have a problem because of the "" (underscore) i'm searching for a solution to overwrite a string even if the string including a "" (underscore);

can some1 help me with this?

Last edited by oferg; 12-05-2016 at 03:46 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Is it possible to replace more the 1 string with one SED?

i want to replace two phrases in text file originalstringA.1. blah blah.... originalstringB.1. got this code so far: #variables IP=$1 NO=$2 FS=$3 IS=$4 NN=1 #echo variables echo '' echo $IP echo $NO echo $FS echo $IS (1 Reply)
Discussion started by: tuathan
1 Replies

2. Shell Programming and Scripting

sed: replace string with another string (with spaces)

Hi I have an XML file with strings XABCD, XEFGHX and XIJKLX. I would like to replace XABCDX with "This is the first string", XEFGHX with "This is the second string" and XIJKLX with "This is the third string". What is the best way to implement this? Should I have a file with the data that is... (4 Replies)
Discussion started by: zmfcat1
4 Replies

3. Shell Programming and Scripting

Using sed to replace a string in file with a string in a variable that contains spaces

Hi, i call my shell like: my_shell "my project name" my script: #!/bin/bash -vx projectname=$1 sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp cp temp test_config_doxy the following error occurres: sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies

4. Shell Programming and Scripting

How to use sed to replace the a string in the same file using sed?

How do i replace a string using sed into the same file without creating a intermediate file? (7 Replies)
Discussion started by: gomes1333
7 Replies

5. UNIX for Dummies Questions & Answers

sed replace string

Hi, How can i execute the below. I want to replace value1 string value with new/new/newString value sed 's/value1/new/new/newString'/' file.txt ~Vinodh' Kumar (2 Replies)
Discussion started by: vino_hymi
2 Replies

6. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

7. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

8. Shell Programming and Scripting

sed String Replace

I have this file and variable on my machine $cat /tmp/disk.tmp check_disk.pl -H localhost -D ARG1 -w 75 -c 90 $echo $_ARG1 /,/opt,/tmp,/usr,/var,/boot,/dev/shm how do I replace the string ARG1 in my file (disk.tmp) with the value of my variable _ARG1 and placing them inside quotes while... (4 Replies)
Discussion started by: thursday_g0ne
4 Replies

9. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

10. Shell Programming and Scripting

Replace String without using sed

Hi Team, I have a file and need to replace string. Out of 20 rows, there is one row given below $Paramsoqlfilter=Systemmodstamp > 1900-01-01T00:00:00.000Z in a Shell Script, I have a variable HIST_DATE="1900-01-01T00:00:00.000Z" INC_DATE="2018-10-04T09:18:43.000Z" Now I need to... (14 Replies)
Discussion started by: ace_friends22
14 Replies
exec_attr(4)                                                                                                                          exec_attr(4)

NAME
exec_attr - execution profiles database SYNOPSIS
/etc/security/exec_attr /etc/security/exec_attr is a local database that specifies the execution attributes associated with profiles. The exec_attr file can be used with other sources for execution profiles, including the exec_attr NIS map and NIS+ table. Programs use the getexecattr(3SECDB) rou- tines to access this information. The search order for multiple execution profile sources is specified in the /etc/nsswitch.conf file, as described in the nsswitch.conf(4) man page. The search order follows the entry for prof_attr(4). A profile is a logical grouping of authorizations and commands that is interpreted by a profile shell to form a secure execution environ- ment. The shells that interpret profiles are pfcsh, pfksh, and pfsh. See the pfsh(1) man page. Each user's account is assigned zero or more profiles in the user_attr(4) database file. Each entry in the exec_attr database consists of one line of text containing seven fields separated by colons (:). Line continuations using the backslash (fR) character are permitted. The basic format of each entry is: name:policy:type:res1:res2:id:attr name The name of the profile. Profile names are case-sensitive. policy The security policy that is associated with the profile entry. The valid policies are suser (standard Solaris superuser) and solaris. The solaris policy recognizes privileges (see privileges(5)); the suser policy does not. The solaris and suser policies can coexist in the same exec_attr database, so that Solaris releases prior to the current release can use the suser policy and the current Solaris release can use a solaris policy. solaris is a superset of suser; it allows you to specify privileges in addition to UIDs. Policies that are specific to the current release of Solaris or that contain privileges should use solaris. Policies that use UIDs only or that are not specific to the current Solaris release should use suser. type The type of object defined in the profile. The only valid type is cmd. res1 Reserved for future use. res2 Reserved for future use. id A string that uniquely identifies the object described by the profile. For a profile of type cmd, the id is either the full path to the command or the asterisk (*) symbol, which is used to allow all commands. An asterisk that replaces the filename component in a pathname indicates all files in a particular directory. To specify arguments, the pathname should point to a shell script that is written to execute the command with the desired argument. In a Bourne shell, the effective UID is reset to the real UID of the process when the effective UID is less than 100 and not equal to the real UID. Depending on the euid and egid values, Bourne shell limitations might make other shells preferable. To prevent the effective UIDs from being reset to real UIDs, you can start the script with the -p option. #!/bin/sh -p attr An optional list of semicolon-separated (;) key-value pairs that describe the security attributes to apply to the object upon execu- tion. Zero or more keys may be specified. The list of valid key words depends on the policy enforced. The following key words are valid: euid, uid, egid, gid, privs, and limitprivs. euid and uid contain a single user name or a numeric user ID. Commands designated with euid run with the effective UID indicated, which is similar to setting the setuid bit on an executable file. Commands designated with uid run with both the real and effective UIDs. Setting uid may be more appropriate than setting the euid on privileged shell scripts. egid and gid contain a single group name or a numeric group ID. Commands designated with egid run with the effective GID indicated, which is similar to setting the setgid bit on a file. Commands designated with gid run with both the real and effective GIDs. Setting gid may be more appropriate than setting guid on privileged shell scripts. privs contains a privilege set which will be added to the inheritable set prior to running the command. limitprivs contains a privilege set which will be assigned to the limit set prior to running the command. privs and limitprivs are only valid for the solaris policy. Example 1: Using Effective User ID The following example shows the audit command specified in the Audit Control profile to execute with an effective user ID of root(0): Audit Control:suser:cmd:::/usr/sbin/audit:euid=0 /etc/nsswitch.conf /etc/user_attr /etc/security/exec_attr CAVEATS
When deciding which authorization source to use (see ), keep in mind that NIS+ provides stronger authentication than NIS. Because the list of legal keys is likely to expand, any code that parses this database must be written to ignore unknown key-value pairs without error. When any new keywords are created, the names should be prefixed with a unique string, such as the company's stock symbol, to avoid potential naming conflicts. The following characters are used in describing the database format and must be escaped with a backslash if used as data: colon (:), semi- colon (;), equals (=), and backslash (fR). auths(1), profiles(1), roles(1), sh(1), makedbm(1M), getauthattr(3SECDB), getauusernam(3BSM), getexecattr(3SECDB), getprofattr(3SECDB), getuserattr(3SECDB), kva_match(3SECDB), auth_attr(4), prof_attr(4), user_attr(4), privileges(5) 25 Feb 2005 exec_attr(4)
All times are GMT -4. The time now is 05:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy