Hi All,
HP-UX oradev3 B.11.11 U 9000/800 3251073457
I have following files all contains text like "919642990137@". I need to search this text across all files and replace it with something like "919717298765@". I was wondering, how to accomplish this task?
cpmprod_status.sh
dflprod_status.sh
image_status.sh
infaprd1_status.sh
infapsp1_status.sh
jdaprod_status.sh
kronp_status.sh
ladr_status.sh
pfin1_status.sh
pfin3_status.sh
pfin4_status.sh
pfin_status.sh
prod01_status.sh
prod02_status.sh
prod03_status.sh
prod04_status.sh
prod05_status.sh
pscc_status.sh
rds01_status.sh
smrtprod_status.sh
hare krishna :o
#!/usr/bin/ksh
while read mFName
do
echo "Now working on <$mFName>"
sed 's/oldtext/newtext/' ${mFName} > Tmp
mv Tmp > ${mFName}
done < File_with_file_names
Hi Shell,
Thanks for your script. I guess, we need to assign this mFName all the file name. right ?? like
mFName="file1,file2..n".
hare krishna
No - I specified "File_with_file_names" and as it implies, it is a file with all file names in it.
Thanks shell, but following is returned, when tried this out. I have ctreated working.txt and put 2 files in it seperated with comma (,).
none> while read mFName
> do
> echo "Now working on <$mFName>"
> sed 's/aajitkumar@csc.com/aajitkumar@csc.com,aajitkumar@csc.com/' ${mFName} > Tmp
> mv Tmp > ${mFName}
> done < working.txt
Now working on <mail.sh,test.sh>
sed: Cannot find or open file mail.sh,test.sh.
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
Now working on <>
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
hare krishna
Why did you create a file separated by comma when your requirement shows one file per line:
cpmprod_status.sh
dflprod_status.sh
...
smrtprod_status.sh
still no luck.
none> while read mFName
> do
> echo "Now working on <$mFName>"
> sed 's/aajitkumar@csc.com/aajitkumar@csc.com,aajitkumar@csc.com/' ${mFName} > Tmp
> mv Tmp > ${mFName}
> done < working.txt
Now working on <mail.sh>
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
Now working on <test.sh>
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
Now working on <>
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
none> cat working.txt
mail.sh
test.sh
hare krishna
Thanks Shell, once again. You seems to have prety good sense of shell scripting. thank you very much, mate!! still wondering, why hpux showing this.
Usage: mv [-f] [-i] [-e warn|force|ignore] f1 f2
mv [-f] [-i] [-e warn|force|ignore] f1 ... fn d1
mv [-f] [-i] [-e warn|force|ignore] d1 d2
hare krishna