how find and replace into different files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how find and replace into different files
# 1  
Old 03-17-2005
how find and replace into different files

Hi,

I have a serie of files in a directory. Into this files I´ve got lines with a serie of numbers like "12344332","1","2","3","4","5","6","7","3","7","7","8","3","7"

I need make some changes on the line where is a specific string, for example numberToIdentify = "12344332". And once identified the line I need work on, I want replace the third and the fith numbers for valueToSub = "1".
I understand that could be something as

read numberToIdentify, valueToSub

for FILE in `ls`
do
while read LINE
do

done
done

Anyhelp could be really useful. thks
ran
# 2  
Old 03-18-2005
sed 's/","/ /g' filename |awk '/12344332/ {$4=1;$6=1;print}'|sed 's/ /","/g'

this doesn't directly replace the line in your original file but hopefully its a start

Last edited by tanku; 03-18-2005 at 05:16 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find all .sh files in file system and need to replace the string inside .sh files

Hi All, I need to write a script to find all "*.sh" files in /home file system and if any string find "*.sh" files with the name vijay@gmail.com need to replace with vijay.bhaskar@gmail.com. I just understood about the find the command to search .sh files. Please help me on this. find / -name... (3 Replies)
Discussion started by: bhas85
3 Replies

2. UNIX for Beginners Questions & Answers

Find and replace from multiple files

Hello everybody, I need your help. I have a php site that was expoited, the hacker has injected into many php files a phishing code that was discovered and removed in order to have again a clean code. Now we need to remove from many php files that malware. I need to create a script that find and... (2 Replies)
Discussion started by: ninocap
2 Replies

3. Shell Programming and Scripting

Find and replace in multiple files

Hi, I have php files in main dir and sub dir's as well. I need to find "new mysqli('localhost', 'System', 'xxxxxx', 'System', '3306');" and replace as "new mysqli('localhost', 'unx_sys', 'yyyy', 'unx_sys', '3306');" I tried like: sed 's/new mysqli\(*\)\;$/new... (1 Reply)
Discussion started by: ashokvpp
1 Replies

4. Shell Programming and Scripting

Find and replace folder of files with $var

I want to scan through all the files in the folder and replace all instances of $file_X within the file with the variable $X defined in my bash script on my debian 6.0 install. For example, if the file contains $file_dep I want it to be replaced with the value of the variable $dep defined in my... (1 Reply)
Discussion started by: Spadez
1 Replies

5. UNIX for Advanced & Expert Users

linux find and replace in multiple files

Is there a reason why all of these examples of linux find and replace in multiple files use find and grep to pipe into sed or perl. Why not just use sed or perl directly with something like this? sed -i 's/echo/burnbaby/g' booboo*... (2 Replies)
Discussion started by: cokedude
2 Replies

6. Shell Programming and Scripting

awk find and replace in multiple files

Hi I use the following code to replace ‘.' with ‘N' in my files and keep both versions. awk '{ gsub(/\./,"N"); print }' file_0001.txt > path/to/new/dir/file_0001.txt I need help on how to apply the code to 100 files instead of doing them one file at a time. The files are labeled... (7 Replies)
Discussion started by: jdhahbi
7 Replies

7. UNIX for Advanced & Expert Users

Find and Replace from files

Is there any command which I can apply from the command line to find and replace a particular text say "00:00:00:00" with "00" from all the files( where ever this text exists) of the current directory? Thanks in advance (1 Reply)
Discussion started by: cobroraj
1 Replies

8. Shell Programming and Scripting

find and replace three lines in files?

Hello, i usually use this for one tag or line: find . -type f -exec replace "whatever goes here" "" -- {} \; but i want to replace three lines in a file for example this: <script language=javascript>< ... (1 Reply)
Discussion started by: Bashar
1 Replies

9. UNIX for Dummies Questions & Answers

Find and replace a string in multiple files

I used the following script cd pathname for y in `ls *`; do sed "s/ABCD/DCBA/g" $y > temp; mv temp $y; done and it worked fine for finding and replacing strings with names etc. in all files of the given path. I'm trying to replace a string which consists of path (location of file) ... (2 Replies)
Discussion started by: pharos467
2 Replies

10. UNIX for Dummies Questions & Answers

find pattern in FILES and replace it ??

Hi How can I looking for a pattern found in more than one file and replace it with anther pattern this what I was used: find . -name "account.adrs" -depth -follow -exec grep -l "Email = ;" {} \; this print the files name -which is account.adrs- and its path -which is deferent for each... (4 Replies)
Discussion started by: tamer
4 Replies
Login or Register to Ask a Question