Sponsored Content
Top Forums Shell Programming and Scripting sed replace spaces between quotes with a variable Post 302401554 by EXT3FSCK on Saturday 6th of March 2010 08:49:02 PM
Old 03-06-2010
Java sed replace spaces between quotes with a variable

I have lines with:

Code:
elseif (req.http.host ~ "^(www.)?edificationtube.com$|www.edificationtube.org www.edificationtube.net edificationtube.org www.edificationtube.com edificationtube.net") {
elseif (req.http.host ~ "^(www.)?collegecontender.com$|www.collegecontender.com collegecontenders.com www.collegecontenders.com") {
elseif (req.http.host ~ "^(www.)?adaxle.com$|www.adaxle.net www.adaxle.com adaxle.net www.adaxle.org www.adaxle.biz adaxle.org adaxle.biz") {

Within a txt file, I want a sed command that would go through only lines that contain "req.http.host", but only replace the spaces within those lines it finds between the quotes, so the end result would look like:

Code:
elseif (req.http.host ~ "^(www.)?edificationtube.com$|www.edificationtube.org|www.edificationtube.net edificationtube.org|www.edificationtube.com|edificationtube.net") {
elseif (req.http.host ~ "^(www.)?collegecontender.com$|www.collegecontender.com|collegecontenders.com|www.collegecontenders.com") {
elseif (req.http.host ~ "^(www.)?adaxle.com$|www.adaxle.net|www.adaxle.com|adaxle.net|www.adaxle.org|www.adaxle.biz|adaxle.org|adaxle.biz") {

Can anyone guide me on how this can be done with sed/awk?

Thanks!
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

How to replace spaces excluding those within double quotes and after backslash?

In bash or perl, I would like to know how to substitute a null character (0x00) for every white space without changing the white spaces inside the block of double quotes and the white space immediately following a backslash. Suppose that sample.txt consists of the following line. "b 1" c\ 2 ... (2 Replies)
Discussion started by: LessNux
2 Replies

3. Shell Programming and Scripting

HELP with AWK or SED. Need to replace the commas between double quotes in CSV file

Hello experts, I need to validate a csv file which contains data like this: Sample.csv "ABCD","I",23,0,9,,"23/12/2012","OK","Street,State, 91135",0 "ABCD","I",23,0,9,,"23/12/2012","OK","Street,State, 91135",0 I just need to check if all the records contain exactly the number of... (5 Replies)
Discussion started by: shell_boy23
5 Replies

4. Shell Programming and Scripting

sed to replace the matching pattern with equal number of spaces

Hi I have written a shell script which used sed code below sed -i 's/'"$Pattern"'/ /g' $FileName I want to count the length of Pattern and replace it with equal number of spaces in the FileName. I have used $(#pattern) to get the length but could not understand how to replace... (8 Replies)
Discussion started by: rakeshkumar
8 Replies

5. Shell Programming and Scripting

sed replace one space and leave other spaces untouched

Hi Friends, I looked up online, but couldn't figure out a proper solution. I have an input file where the columns are separated by multiple spaces and the column content is separated by single space. For example, Chr1 hello world unix is fun In the above example, chr1 is first... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

6. Shell Programming and Scripting

sed command to replace string that contain blackslash,double quotes

Hi All, I have been trying to replace a string using the sed command string value contain blackslash and double quotes. I am not a expert writer of unix script but do try not to ask question. I have almost given up. Hope you all can give me some suggestion I want to replace a place string... (6 Replies)
Discussion started by: thanush9sep
6 Replies

7. UNIX for Dummies Questions & Answers

Need help with sed replace script to include spaces

I've got a sed shell script I've been using for quite a while to do batch find/replace operations on .xml files containing various types of text entries. This is the script I use: #!/bin/bash while read text_old text_new; do sed_script+="s/$text_old/$text_new/g;" done < trans_old_to_new... (9 Replies)
Discussion started by: Agreppa
9 Replies

8. Shell Programming and Scripting

Replace delimeter between quotes with \| using sed or awk

I've a pipe delimited data in a file of size 3GB. if the text data conatins pipe delimiter that will be enclose with double quotes. I have to replace delimiter which exists between double quotes with #%@#%@#%@ using awk or sed. can some one provide a better and efficient solution to me. The below... (4 Replies)
Discussion started by: BrahmaNaiduA
4 Replies

9. UNIX for Beginners Questions & Answers

sed command to replace consecutive double quotes

I need to replace consecutive double quotes in a csv file, the data in the file is enclosed in double quotes but there are some places where the quotes are repeating Example is below Incoming data is : "Pacific Region"|"PNG"|"Jimmy""|""| Need output as: "Pacific... (10 Replies)
Discussion started by: abhilashnair
10 Replies

10. Shell Programming and Scripting

Spaces in double quotes in variable ?

Hi got this issue and was wondering if someone could please help out ? var='." "' echo $var ." " I 'll get ." " and not ." with 10 spaces in between " Thanks (3 Replies)
Discussion started by: stinkefisch
3 Replies
gnutls_ocsp_req_get_nonce(3)					      gnutls					      gnutls_ocsp_req_get_nonce(3)

NAME
gnutls_ocsp_req_get_nonce - API function SYNOPSIS
#include <gnutls/ocsp.h> int gnutls_ocsp_req_get_nonce(gnutls_ocsp_req_t req, unsigned int * critical, gnutls_datum_t * nonce); ARGUMENTS
gnutls_ocsp_req_t req should contain a gnutls_ocsp_req_t structure unsigned int * critical whether nonce extension is marked critical, or NULL gnutls_datum_t * nonce will hold newly allocated buffer with nonce data DESCRIPTION
This function will return the OCSP request nonce extension data. The caller needs to deallocate memory by calling gnutls_free() on nonce ->data. RETURNS
On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a negative error code is returned. REPORTING BUGS
Report bugs to <bug-gnutls@gnu.org>. General guidelines for reporting bugs: http://www.gnu.org/gethelp/ GnuTLS home page: http://www.gnu.org/software/gnutls/ COPYRIGHT
Copyright (C) 2012 Free Software Foundation, Inc.. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. SEE ALSO
The full documentation for gnutls is maintained as a Texinfo manual. If the info and gnutls programs are properly installed at your site, the command info gnutls should give you access to the complete manual. As an alternative you may obtain the manual from: http://www.gnu.org/software/gnutls/manual/ gnutls 3.1.15 gnutls_ocsp_req_get_nonce(3)
All times are GMT -4. The time now is 10:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy