![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 07: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 04: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 |
|
#8
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
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 ? |
|
#10
|
||||
|
||||
|
Thank you ennstate,
You are right, the "find ." will list everything, including the directories. Also, there is no need for "-name '*'" nor "-print". The "find . -type -f" is sufficient to list all regular files and not directories. Thanks. |
|
#11
|
|||
|
|||
|
Hi,
Do I run this on the command line or do I have to run this command in a script ? |
|
#12
|
||||
|
||||
|
dannyd,
The best way to run this is: 1) Create a file with the above commands. 2) Change its permissions to executable (ie 755, etc.). 3) Type the file name in the command line. |
|
#13
|
|||
|
|||
|
no need the for loop
Code:
find . -size +1024c -type f -name "*.txt" -print0 | xargs -0 sed -i 's/term/replace/g' |
|
#14
|
|||
|
|||
|
Quote:
Wouldnt this search only files that end with .txt and would it search subfolders ? |
|||
| Google The UNIX and Linux Forums |