![]() |
|
|
|
|
|||||||
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 06:24 AM |
| Search and Replace in Ksh | DeepakXavier | Shell Programming and Scripting | 9 | 05-28-2007 05:11 AM |
| sed search and replace | d__browne | UNIX for Dummies Questions & Answers | 7 | 04-26-2006 06:46 AM |
| Search and replace sed or tr | bridgeje | Shell Programming and Scripting | 6 | 10-28-2003 03:54 AM |
| search and Replace | mukeshannamalai | UNIX for Advanced & Expert Users | 4 | 09-14-2001 03:21 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
search and replace
I have a I need to replace all instances of the word mysite.com to maysite.net within the public_html web folder. How can I accomplish this.
|
| Forum Sponsor | ||
|
|
|
|||
|
Sorry I dont think i was clear in my question. I would like to replace all instances of the word mysite.com to mysite.net inside every file in the entire website.
I think your solution searches for files with the name mysite.com and renames them to mysite.net. |
|
|||
|
No. You didn't specify it in your request.
Quote:
I dont think we may require `ls -1` in the for loop in case we are listing the files/directories in the Current working directory just an * will do. Also note `find .` or `ls -1` or simple * will list all files & directories,so we may to have use, Quote:
Thanks Nagarajan Ganesan |
|
|||
|
So I guess this would be the final solution ?
for file in $(find . -name '*' -type f -print ) ; do sed 's/mysite.com/mysite.net/g' $FileName > $$TempFile mv $$TempFile $FileName done If i want to run this command do I type this out on the command line or do i have to make a shell script and run the shell script ? |
|
|||
|
Quote:
Wouldnt this search only files that end with .txt and would it search subfolders ? |
| Thread Tools | |
| Display Modes | |
|
|
|
The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
|
| 421 service not available, remote server has closed connection ^m autosys awk trim bash eval bash exec bash for loop command copy/move folder in unix couldn't set locale correctly curses.h cut command in unix daemon process export command in unix find grep find mtime find null character in a unix file grep multiple lines grep or grep recursive hp-ux ifconfig inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude tar extract to folder test: argument expected unix unix .profile unix forum unix forums unix internals unix interview questions unix simulator unix.com vi select all vi substitute vi+substitute+end+of+line+character while loop within while loop shell script |