Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replacing URL in a file with space Post 302171627 by bakunin on Friday 29th of February 2008 03:58:18 AM
Old 02-29-2008
To rephrase your problem: you search for a string of the form "http://...." enclosed in double quotes and ending in a white space, yes?

Further, we do not have to consider the end-of-line situation, as the URL will always be part of some HTML-tag and therefore cannot be at the end of the line. (Otherwise we would have to consider the two cases '"http://..." ' and '"http://...."$'.)

Then the solution is:

Code:
sed 's/"http:\/\/[^ ]*dtd"/ /' file1 > file2

The reason why you code didn't work was:

Code:
cat File1.txt | sed -e 's/("http)*(dtd")/ /g' > File2.txt

First, the bracket ("()") are just simple characters if you do not escape them: "\(...\)". As you have no brackets in your search string this must fail.

Second, even if that were grouping characters the asterisk ("*") after "http" would then make the whole group optional. "*" is not "any string" like in DOS, but "the last expression zero or more times".

So, what you have been searching for was: the literal string '("http' followed by an optional ')', followed by '(dtd")'.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replacing single space in argument

I want to write a script which will check the arguments and if there is a single space(if 2 more more space in a row , then do not touch), replace it with _ and then gather the argument so, program will be ran ./programname hi hello hi usa now hello hello so, inside of program,... (7 Replies)
Discussion started by: convenientstore
7 Replies

2. UNIX for Dummies Questions & Answers

replacing space with pipe(delimiter)

Hello All, I have a file with thousands of records: eg: |000222|123456987|||||||AARONSON| JOHN P|||PRIMARY |P |000111|567894521|||||||ATHENS| WILLIAM k|||AAAA|L Expected: |000222|123456987|||||||AARONSON| JOHN |P|||PRIMARY |P |000111|567894521|||||||ATHENS| WILLIAM |k|||AAAA|L I... (6 Replies)
Discussion started by: OSD
6 Replies

3. Shell Programming and Scripting

replacing all space seperates with tabs

hi, I have a file that is space separated at all columns. Basically what I want to do is replace all the space separations with column separations. Thanks kylle (1 Reply)
Discussion started by: kylle345
1 Replies

4. UNIX for Advanced & Expert Users

sed help on replacing space before and after *

I would like to replace the value of * (which might have one or more whitespace(s) before and after *) using sed command in aix. Eg: Var='Hi I am there * Desired output: Hi I am there* (1 Reply)
Discussion started by: techmoris
1 Replies

5. Shell Programming and Scripting

Suppressing space replacing by comma

hi i want to replace spaces by comma my file is ADD 16428 170 160 3 WNPG 204 941 No 204802 ADD 16428 170 160 3 WNPG 204 941 No 204803 ADD 16428 170 160 3 WNPG 204 941 No 204804 ADD... (9 Replies)
Discussion started by: raghavendra.cse
9 Replies

6. Shell Programming and Scripting

Replacing a string with a space

I'm trying to replace a string "99999999'" with the blank where ever is there in the file. Could you please help in unix scripting. Thank You. (6 Replies)
Discussion started by: vsairam
6 Replies

7. Shell Programming and Scripting

Replacing space with T only in the 1st line of the file

Hi Masters , I have a file whose header is like HDRCZECM8CZCM000000881 SVR00120100401160828+020020100401160828+0200CZK There is a space between 1 and S ,my req is to chng the space to T I tried echo `head -1 CDCZECM8CZCM000000881` | sed 's/ /T/' it works ,but how can I modify in... (5 Replies)
Discussion started by: Pratik4891
5 Replies

8. Shell Programming and Scripting

Replacing / with a space using awk

I have a string and want to replace the / with a space. For example having "SP/FS/RP" I want to get "SP FS RP" However I am having problems using gsub set phases = `echo $Aphases | awk '{gsub(///," ")}; {print}'` (5 Replies)
Discussion started by: kristinu
5 Replies

9. Web Development

Negate user space URL in Apache

Hello, I have a situation where I am trying to use Apache's RedirectMatch directive to redirect all users to a HTTPS URL except a single (Linux) user accessing there own webspace. I have found a piece of regular expression code that negates the username: ^((?!andy).)*$but when I try using it... (0 Replies)
Discussion started by: LostInTheWoods
0 Replies

10. Shell Programming and Scripting

Reading URL using Mechanize and dump all the contents of the URL to a file

Hello, Am very new to perl , please help me here !! I need help in reading a URL from command line using PERL:: Mechanize and needs all the contents from the URL to get into a file. below is the script which i have written so far , #!/usr/bin/perl use LWP::UserAgent; use... (2 Replies)
Discussion started by: scott_cog
2 Replies
DACS_LIST_JURISDICTI(8) 				     DACS Web Services Manual					   DACS_LIST_JURISDICTI(8)

NAME
dacs_list_jurisdictions - display information about DACS jurisdictions SYNOPSIS
dacs_list_jurisdictions [dacsoptions[1]] DESCRIPTION
This web service is part of the DACS suite. The dacs_list_jurisdictions web service displays information, relative to the jurisdiction that receives the request, about its federation and other jurisdictions in that federation. Included are the federation's public encryption key and its unique instance identifier. The FORMAT argument (see dacs.services(8)[2]) determines the type of output, with the default being HTML, using the style sheet dacs_list_jurisdictions.css[3]. The various flavours of XML, a PHP format (see below), JSON, and plain text (TEXT) are supported. One application of dacs_list_jurisdictions is to assist middleware to generate a menu of jurisdictions for user authentication. If FORMAT is PHP, a list of each jurisdiction that provides an authentication service is emitted (as text/plain, one jurisdiction per line. Each line has the format: jurisdiction[]=jname&host[]=url&jname The string jname is the DACS jurisdiction name and url is the complete URL prefix for DACS web services at the jurisdiction. For example, invoking this URL: https://example.com/infocards/cgi-bin/dacs/dacs_list_jurisdictions?FORMAT=PHP might return the following response: jurisdiction[]=INFOCARDS&host[]=https://example.com/infocards/cgi-bin/dacs&INFOCARDS jurisdiction[]=DEMO&host[]=https://example.com/demo/cgi-bin/dacs&DEMO jurisdiction[]=TEST&host[]=https://test.example.com/cgi-bin/dacs&TEST The html/examples/login.php[4] template demonstrates this feature. If XML output is selected, a document conforming to dacs_list_jurisdictions.dtd[5] is returned. When returned as an XML attribute, a public encryption key is a base-64 encoding of the PEM formatted key. Note This program is also available as a DACS utility, dacslist(1)[6]. Because dacs_admin(8)[7] provides the same functionality and more, dacs_list_jurisdictions may be removed in a future release. Web Service Arguments In addition to the standard CGI arguments[8], dacs_list_jurisdictions understands the following CGI arguments: JURISDICTION Limit the output to the specified jurisdiction name. As a special case, if the argument does not specify a jurisdiction name, only federation-scoped information will be returned. PUB_KEY_ONLY If this argument is "yes" (case insensitive) only the federation's or a jurisdiction's public key (if known) will be returned. If JURISDICTION is given and is not the empty string, that jurisdiction name is selected; if JURISDICTION is given and is the empty string, the federation is selected; and if the argument is absent, the current jurisdiction is selected. This argument currently requires FORMAT to be TEXT. A PEM [RFC 1421[9], RFC 1422[10], RFC 1423[11], RFC 1424[12]] formatted key is returned. Note In the current implementation, a jurisdiction's public key can only be provided by one of the jurisdictions configured on the same host. FILES
dacs_list_jurisdictions.css[3] DIAGNOSTICS
The program exits 0 if everything was fine, 1 if an error occurred. SEE ALSO
dacs(1)[13], dacskey(1)[14], dacslist(1)[6], dacs.groups(5)[15] AUTHOR
Distributed Systems Software (www.dss.ca[16]) COPYING
Copyright2003-2012 Distributed Systems Software. See the LICENSE[17] file that accompanies the distribution for licensing information. NOTES
1. dacsoptions http://dacs.dss.ca/man/dacs.1.html#dacsoptions 2. dacs.services(8) http://dacs.dss.ca/man/dacs.services.8.html#FORMAT 3. dacs_list_jurisdictions.css http://dacs.dss.ca/man//css/dacs_list_jurisdictions.css 4. html/examples/login.php http://dacs.dss.ca/man/../examples/login.php 5. dacs_list_jurisdictions.dtd http://dacs.dss.ca/man/../dtd-xsd/dacs_list_jurisdictions.dtd 6. dacslist(1) http://dacs.dss.ca/man/dacslist.1.html 7. dacs_admin(8) http://dacs.dss.ca/man/dacs_admin.8.html 8. standard CGI arguments http://dacs.dss.ca/man/dacs.services.8.html#standard_cgi_args 9. RFC 1421 http://www.rfc-editor.org/rfc/rfc1421.txt 10. RFC 1422 http://www.rfc-editor.org/rfc/rfc1422.txt 11. RFC 1423 http://www.rfc-editor.org/rfc/rfc1423.txt 12. RFC 1424 http://www.rfc-editor.org/rfc/rfc1424.txt 13. dacs(1) http://dacs.dss.ca/man/dacs.1.html 14. dacskey(1) http://dacs.dss.ca/man/dacskey.1.html 15. dacs.groups(5) http://dacs.dss.ca/man/dacs.groups.5.html 16. www.dss.ca http://www.dss.ca 17. LICENSE http://dacs.dss.ca/man/../misc/LICENSE DACS 1.4.27b 10/22/2012 DACS_LIST_JURISDICTI(8)
All times are GMT -4. The time now is 11:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy