Sponsored Content
Full Discussion: Bulk Find and Replace
Top Forums Shell Programming and Scripting Bulk Find and Replace Post 302677639 by Vryali on Thursday 26th of July 2012 12:11:33 PM
Old 07-26-2012
Lots of whats to do this, but simply done like this:

Code:
$ cat *.html | sed 's/\(.*taskid=\)\([0-9]*\)\(.*$\)/\133528\3/g' 
http://unix.com/cgi-bin/task?taskid=33528&task.out
http://unix.com/cgi-bin/task?taskid=33528&task.out
http://unix.com/cgi-bin/task?taskid=33528&task.out
http://unix.com/cgi-bin/task?taskid=33528&task.out

So in a find statement:
Code:
for file in $(find /dir -name '*.html' -print); do
    sed 's/\(.*taskid=\)\([0-9]*\)\(.*$\)/\133528\3/g' ${file} > /tmp/tmp.file
    mv /tmp/tmp.file ${file}
    # If needed to fix permissions and ownership
    chmod XXX ${file}
    chown X:X ${file}
done

Edit:

You were close on your sed statement, here's what you probably were going for that route:
Code:
$ cat *.html | sed 's/taskid=[0-9]*/taskid=123456/g'
http://unix.com/cgi-bin/task?taskid=123456&task.out
http://unix.com/cgi-bin/task?taskid=123456&task.out
http://unix.com/cgi-bin/task?taskid=123456&task.out
http://unix.com/cgi-bin/task?taskid=123456&task.out


Last edited by Vryali; 07-27-2012 at 02:51 PM..
This User Gave Thanks to Vryali For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find and replace

I have a file that I want to remove all of the periods from. I am using the below to remove quotations and it works fine -I thought I could make it work for the period but it does not. Any help would be appreciated. works to remove the double quote mark (") sed -e 's/"//g' input file... (4 Replies)
Discussion started by: valhutch
4 Replies

2. UNIX for Dummies Questions & Answers

find and replace

I have statement like this column_id.columnname=="value" in unix i want to modify above statement to variable1=="value" that means i have to replace the string before "==" by string "variable1" second catch is, in statement instead of "==" you can have any arithmatic comarision... (7 Replies)
Discussion started by: mahabunta
7 Replies

3. UNIX for Advanced & Expert Users

Please help with find and replace:

Hi I am trying to find a product code hightlighted in red, and re-insert it at another place on the same file. I shall be grateful if anyone can help me with this. Stuck and have deadline!!:confused: Original Line: (I can get source data in one of these two formats) ISD=977155185403901+DIE... (2 Replies)
Discussion started by: gloovy_tb
2 Replies

4. Shell Programming and Scripting

find and replace

Hi, There are some "n" files in a directory which contains comman string.A command to find and replace the string in all the files without looping. like if i am in a directory : # find ./ -name ".txt" | xargs sed -e 's/test/tst' Upto here is performed correctly and i want to... (4 Replies)
Discussion started by: rakshit
4 Replies

5. Shell Programming and Scripting

find replace

Hi I am replacing some string occurances with empty string in all files under one directory using find ./ -name "*.dmp" | xargs perl -pi -e 's/\\N//g' | its taking too much time for replacing and redirecting to same file in the same directory. Similarly afterwards i am finding last... (2 Replies)
Discussion started by: dbsurf
2 Replies

6. UNIX for Dummies Questions & Answers

Find and Replace

After running a command like grep -ir files2/ * This will find all the files that contain "files2/" in it. For example if it finds files2/dir/today files2/dir/yesterday files2/dir/2daysago Now it may find 100 instances, so is there a quick find and replace command I can use? I... (4 Replies)
Discussion started by: NycUnxer
4 Replies

7. Shell Programming and Scripting

find and replace

Hi I am very new to shell scripting (and linux in general)... I am trying to build some script, that will read a person from a csv file, (each person will have an ID, eg id001abc, which will go up one by one a few hundred times) then when find and replace the matching data in an xml file. ... (4 Replies)
Discussion started by: sam.breslin
4 Replies

8. Shell Programming and Scripting

Shell or perl script to replace XML text in bulk

Hi, I am looking for assistance over shell or perl (without XML twig module) which replace string in XML file under particular branch..example of code file sample.. Exact requirment : Replace "Su saldo es" in below file with "Your balance" but only in XML branch of Text id=98 and Text Id=12... (7 Replies)
Discussion started by: Ashu_099
7 Replies

9. Shell Programming and Scripting

Bulk find in UNIX at unknown dir location

Dear All, I have a file which is having a number my_file.csv 032001031 100509001 203001165 there are many more about 5000. I have a path in unix /my_path/my_loc/DEV/RPD10/CPD25/WFM/RK_WFM/OUT/*/ where i will have a file like CPD25_203001165.pdf CPD25_100509001.pdf... (4 Replies)
Discussion started by: yadavricky
4 Replies

10. Shell Programming and Scripting

Find and replace

Hi Team, one silly issue. but its not working for me. I need to find a pattern a file and replace it with the given value in another file. Here's the code snippet. Search_String=100 Replace_String=151 cat ${work}/temp_${CSV_File} | sed 's|"${Search_String}"|"${Replace_String}"|g'... (2 Replies)
Discussion started by: kmanivan82
2 Replies
AUTHLIB(3)						      Double Precision, Inc.							AUTHLIB(3)

NAME
authlib - Courier Authentication Library SYNOPSIS
courierauthconfig [[--ldflags] | [--cppflags]] DESCRIPTION
The Courier authentication library consists of two libraries: -lcourierauth Authentication functions. -lcourierauthsasl SASL authentication functions. courierauthconfig --cppflags produces on standard output any necessary compiler flags that are needed to access the courierauth.h and the courierauthsasl.h header files. courierauthconfig --ldflags produces on standard output any necessary compiler flags that are needed to link against the courierauth or courierauthsasl libraries. SEE ALSO
auth_generic(3)[1], auth_login(3)[2], auth_getuserinfo(3)[3], auth_enumerate(3)[4], auth_passwd(3)[5], auth_sasl(3)[6]. NOTES
1. auth_generic(3) auth_generic.html 2. auth_login(3) auth_login.html 3. auth_getuserinfo(3) auth_getuserinfo.html 4. auth_enumerate(3) auth_enumerate.html 5. auth_passwd(3) auth_passwd.html 6. auth_sasl(3) auth_sasl.html Double Precision, Inc. 08/23/2008 AUTHLIB(3)
All times are GMT -4. The time now is 12:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy