The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
searching for content of files Aretai UNIX for Dummies Questions & Answers 19 03-09-2007 06:44 AM
Cleaning the content of log files jyotipg Shell Programming and Scripting 1 11-15-2006 02:19 AM
Mass Change content in all files terala Shell Programming and Scripting 1 11-20-2005 01:30 AM
Use of unzip with content files > 2Gb tcarlson Filesystems, Disks and Memory 2 09-17-2003 05:33 PM
Compare the content of 2 files odogbolu98 Shell Programming and Scripting 3 09-10-2002 12:44 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2006
swchee swchee is offline
Registered User
  
 

Join Date: May 2006
Posts: 2
content need changes- many files

Hi, all

Need some advise on this script

i have some files in a directory, and i need to change the word XX in each files to YY, how can i perform a bulk changes/

thanks in advance for yr sharing
  #2 (permalink)  
Old 10-05-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
Try
Code:
#! /bin/ksh
for i in *; do
sed 's/XX/YY/g' $i > $i.tmp
mv $i.tmp $i
done
  #3 (permalink)  
Old 10-05-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
That's completely true if you want to make those changes inside each file. If you want to chage just filemanes:
Code:
#! /bin/ksh
for f in *; do
new_name=$(echo $f | sed 's/XX/YY/')
mv "$f" "$new_name"
done

Regards.
  #4 (permalink)  
Old 10-05-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
using perl

Code:
perl -pi -e "s/XX/YY/g" *
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0