Sponsored Content
Full Discussion: find and replace urls
Top Forums UNIX for Dummies Questions & Answers find and replace urls Post 302244414 by era on Wednesday 8th of October 2008 02:26:25 AM
Old 10-08-2008
To recurse the whole directory structure, you want find

Code:
find path/to/topleveldirectory -type f \
  -exec perl -pi -e s%http://www.mydomain.com/mysubfolder/%./%g {} \;

This will update the time stamp of all files, and needlessly rewrite those which don't contain any match. If that's a problem, perhaps grep for the string first, and only process the files which match.

Code:
find path/to/topleveldir -type f -exec sh -c '
    grep http://www.mydomain.com/mysubfolder/ {} >/dev/null &&
    perl -pi -e s%http://www.mydomain.com/mysubfolder/%./%g {}' \;

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find and replace and keep

Hi All I've file in which has these lines in it create fil23456 read on 3345 create fil23456_1 read on 34567 create fil23456_2 read on 36789 I'm trying to replace the lines in such a way that in the end the file will look like create fil23456 read on 3345 alter fil23456 read on... (3 Replies)
Discussion started by: Celvin VK
3 Replies

2. Shell Programming and Scripting

find and replace

find . -type f -exec sed -i 's/000/333/' {} \; grep -A 1 'height' filename How to modify the command and replace only strings which is below the line which contains the string "height" If the line contains "000", then replace with '333'. (2 Replies)
Discussion started by: sandy1028
2 Replies

3. Shell Programming and Scripting

find and replace

Hi, I have to grep value from one file, if that value is already present with "#" symbol. I have to remove that symbol in that file. Ex: file1.txt contains the following string #value=15 I have to search for "Value". If I found the string with hash symbol, nee to remove the # in... (6 Replies)
Discussion started by: ckchelladurai
6 Replies

4. Homework & Coursework Questions

How is it possible to include URLs within the terminal?

I have noted that Oracle use some kind of hypermarking to create URLs within the terminal on Enterprise Linux. Any idea how to create a URL such as ..., which when right clicked opens a browser window? This supposed to be spam/advertisement? Got a PM from OP; it is not supposed to be spam... (1 Reply)
Discussion started by: jon80
1 Replies

5. Shell Programming and Scripting

Hashing URLs

So, I am writing a script that will read output from Bulk Extractor (which gathers data based on regular expressions). My script then reads the column that has the URL found, hashes it with MD5, then outputs the URL and hash to a file. Where I am stuck on is that I want to read the bulk... (7 Replies)
Discussion started by: twjolson
7 Replies

6. Web Development

How to redirect URLs in Apache?

I am a total newbie to Apache. I need to do this only for this weekend during an upgrade from old system to new system We have different URLs http://domain.name/xxx (xxx varies to any length and words - it can be /home, /login, /home/daily, /daily/report, etc). How do i redirect all those to... (0 Replies)
Discussion started by: GosarJunk
0 Replies

7. Post Here to Contact Site Administrators and Moderators

Not allowed to post URLs

Hi, I tried to post some perl code for discussion (wrapped in swaddling . However, a regex has an escaped backslash so the forum parser sees it as an URL? Had the same experience with the sample data that I tried to provide for the same discussion. It contains emails addresses,... (1 Reply)
Discussion started by: msutfin
1 Replies

8. Shell Programming and Scripting

Replacing urls from file

Hi ALL, I have a file A which contains A=www.google.com B=www.abcd.com C=www.nick.com D=567 file B Contains A=www.google1234.com B=www.bacd.com C=www.mick.com D=789 I wanted a script which can replace file A contents with B Contents (5 Replies)
Discussion started by: nikhil jain
5 Replies

9. Shell Programming and Scripting

Regex for URLs and files

Hi, I am looking for a regex that will validate a URL and files accessed in a browser. For example:http://www.google.co.uk http://www.google.com https://www.google.co.uk https://www.google.com ftp:// file:///somefile/on/a/server/accessed/from/browser/file.txt So far I have: ... (4 Replies)
Discussion started by: muay_tb
4 Replies
ARCHIVE(8)						      System Manager's Manual							ARCHIVE(8)

NAME
archive - Usenet article archiver SYNOPSIS
archive [ -a archive ] [ -f ] [ -i index ] [ -m ] [ -r ] [ input ] DESCRIPTION
Archive makes copies of files specified on its standard input. It is normally run either as a channel feed under innd(8), or by a script before expire(8) is run. Archive reads the named input file, or standard input if no file is given. The input is taken as a set of lines. Blank lines and lines starting with a number sign (``#'') are ignored. All other lines should specify the name of a file to archive. If a filename is not an absolute pathname, it is taken to be relative to /var/spool/news. Files are copied to a directory within the archive directory, /var/spool/news/news.archive. The default is to create a hierarchy that mim- ics the input files; intermediate directories will be created as needed. For example, the input file comp/sources/unix/2211 (article 2211 in the newsgroup comp.sources.unix) will be copied to /var/spool/news/news.archive/comp/sources/unix/2211. OPTIONS
-a archive If the ``-a'' flag is used then its argument specifies the directory to archive in instead of the default. -f If the ``-f'' flag is used, then all directory names will be flattened out, replacing the slashes with periods. In this case, the file would be copied to /var/spool/news/news.archive/comp.sources.unix/2211. -i If the ``-i'' flag is used, then archive will append one line to the specified index file for each article that it copies. This line will contain the destination name and the Message-ID and Subject headers. -m Files are copied by making a link. If that fails a new file is created. If the ``-m'' flag is used, then the file will be copied to the destination, and the input file will be replaced with a symbolic link pointing to the new file. -r By default, archive sets its standard error to /var/log/news/errlog. To suppress this redirection, use the ``-r'' flag. EXIT STATUS
If the input is exhausted, archive will exit with a zero status. If an I/O error occures, it will try to spool its input, copying it to a file. If there was no input filename, the standard input will be copied to /var/spool/news/out.going/archive and the program will exit. If an input filename was given, a temporary file named input.bch (if input is an absolute pathname) or /var/spool/news/out.going/input.bch (if the filename does not begin with a slash) is created. Once the input is copied, archive will try to rename this temporary file to be the name of the input file, and then exit. EXAMPLES
A typical newsfeeds(5) entry to archive most source newsgroups is as follows: source-archive :!*,*sources*,!*wanted*,!*.d :Tc,Wn :/usr/lib/news/bin/archive -f -i /usr/spool/news/news.archive/INDEX HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.14, dated 1996/10/29. SEE ALSO
newsfeeds(5). ARCHIVE(8)
All times are GMT -4. The time now is 09:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy