Sponsored Content
Top Forums Shell Programming and Scripting Passing unix command to "sed" Post 302352379 by skmdu on Friday 11th of September 2009 06:53:56 AM
Old 09-11-2009
I related your last two post, and i tried the following..
Hope this will remove your blocking... Smilie

$cat file

DEV_1_SOURCE_DATABASE=server1
DEV_1_SOURCE_AUDIT_DATABASE= server1
DEV_1_TARGET_DATABASE=server4
DEV_1_TARGET_AUDIT_DATABASE=server4

DEV_2_SOURCE_DATABASE=server2
DEV_2_SOURCE_AUDIT_DATABASE= server2
DEV_2_TARGET_DATABASE=server5
DEV_2_TARGET_AUDIT_DATABASE=server5

Solution 1:

script1.sh
a=` cat file | grep -w "DEV_2_TARGET_DATABASE" | cut -d '=' -f 2`
sed "s/\($a\)/newdb/g" file > file1
mv file1 file

The above script will take the value assigned for DEV_2_TARGET_DATABASE, and substitute that value i.e "server5" to newdb in the whole file content. ( even for DEV 4 or DEV 3)

Solution 2:

If you want to substitute only DEV_2_TARGET_DATABASE=server5 to DEV_2_TARGET_DATABASE=newdb

sed "s/\(DEV_2_TARGET_DATABASE=\)\(.*\)/\1newdb/g" file

Hope this helps..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix "sed" command

Hello , I just wanted to know how to apend to a text in a file using "sed" command. suppose i have a text "Jaya" in the file "name". I wanted to append "thirtha" to it ,so that it displays "Jayathirtha" as a whole. Help me out. Thank You, Jay. Hi, sed -e 's/$/thirtha' <filename>... (1 Reply)
Discussion started by: Jayathirtha
1 Replies

2. UNIX for Dummies Questions & Answers

Unix "at" / "Cron" Command New Problem...Need help

Hi All, I am trying to schedule a one time job using the at command with the help of shell script for my project. The shell script should take a parameter as a command line argument from the at command itself. Is it possible to take a command line parameter for a shell script in the command... (3 Replies)
Discussion started by: Mohanraj
3 Replies

3. Shell Programming and Scripting

about "sed" command in unix

hi i want to append a string to some selected lines in a file. how to do that using sed? if the file looks like this hello i am here welcome to the blk hello how are you unix roollls!! windows, what is that?? i want to append string "fine" to the end of all lines starting with... (2 Replies)
Discussion started by: gopsman
2 Replies

4. Shell Programming and Scripting

passing a list of dynamic names to a "PS" command in shell script?

Hi, I am new to shell script. This is my first post .I have written a small script which returns list of names starts with "ram" in /etc/passwd .Here is that:- #!/bin/ksh NAME_LIST="name_list.txt" cat /dev/null > $NAME_LIST evalcmd="cat /etc/passwd | grep "^ram?*" | cut -d: -f1" eval... (3 Replies)
Discussion started by: sachin.tendulka
3 Replies

5. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

8. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies
GENTEST(1)							  [FIXME: manual]							GENTEST(1)

NAME
gentest - Run random generic SMB operations against two SMB servers and show the differences in behavior SYNOPSIS
gentest {//server1/share1} {//server2/share2} {-U user%pass} {-U user%pass} [-s seed] [-o numops] [-a] [-A] [-i FILE] [-O] [-S FILE] [-L] [-F] [-C] [-X] DESCRIPTION
gentest is a utility for detecting differences in behaviour between SMB servers. It will run a random set of generic operations against //server1/share1 and then the same random set against //server2/share2 and display the differences in the responses it gets. This utility is used by the Samba team to find differences in behaviour between Samba and Windows servers. OPTIONS
-U user%pass Specify the user and password to use when logging on on the shares. This parameter is mandatory and has to be specified twice. -s seed Seed the random number generator with the specified value. -o numops Set the number of operations to perform. -a Print the operations that are performed. -A Backtrack to find minimal number of operations required to make the response to a certain call differ. -i FILE Specify a file containing the names of fields that have to be ignored (such as time fields). See below for a description of the file format. -O Enable oplocks. -S FILE Set preset seeds file. The default is gentest_seeds.dat. -L Use preset seeds -F Fast reconnect (just close files) -C Continuous analysis mode -X Analyse even when the test succeeded. VERSION
This man page is correct for version 4.0 of the Samba suite. SEE ALSO
Samba AUTHOR
This utility is part of the Samba[1] suite, which is developed by the global Samba Team[2]. gentest was written by Andrew Tridgell. This manpage was written by Jelmer Vernooij. NOTES
1. Samba http://www.samba.org/ 2. Samba Team http://www.samba.org/samba/team/ [FIXME: source] 04/16/2014 GENTEST(1)
All times are GMT -4. The time now is 05:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy