search and replace dynamic data in a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search and replace dynamic data in a shell script
# 8  
Old 10-21-2003
Perderabo,

Is there a way to set IFS only for reading in from inputfile? While I am reading in my lines, I want to do something like this:

for s in `echo $my_var | sed 's/./& /g'; do
blah...
done

But if my IFS is set to "," the above mentioned for-loop doesn't work. As a temporary solution, I unset IFS before the loop and reset IFS to "," after the loop. Is this the only way or is there another way? My way kinda seems dumb... :-p

Thanks.
# 9  
Old 10-21-2003
I think that this will work....

while IFS=, read n1 n2 n3 ; do
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies

2. Shell Programming and Scripting

Search and replace data

FILENAME: (Orig File) lab computer11node1 { hardware ok 19:50:56:bd:03:c2; MAC-ADDRESS 10.1.1.1; } lab computer11node2 { hardware ok 19:50:56:bd:03:c3; MAC-ADDRESS 10.1.1.2; } FILENAME2: computer11node1 11:50:56:81:33:c5 computer11node2 11:50:56:81:33:c6 computer11node3 11:50:56:81:33:c7... (5 Replies)
Discussion started by: kenshinhimura
5 Replies

3. Shell Programming and Scripting

Dynamic search and replace

Hi, I am trying to search and replace a value in a file. File contains data which is stated below ruby ./scripts/CreateUsage.rb Cloud_Computing_001 Cloud_Computing_001 is the 3rd column of the file. I want to replace this Cloud_Computing_001 with the runtime value. Next time i want to... (4 Replies)
Discussion started by: Chandresh Kumar
4 Replies

4. UNIX for Dummies Questions & Answers

Shell script for search and replace by field

Hi, I have an input file with below data and rules file to apply search and replace by each field in the input based on exact value or pattern. Could you please help me with unix script to read input file and rules file and then create the output and reject files based on the rules file. Input... (13 Replies)
Discussion started by: chandrath
13 Replies

5. Shell Programming and Scripting

Reading the data from CSV and performing search through shell script

Hello, I am working on building a script that does the below actions together in my Linux server. 1) First, have to read the list of strings mentioned in CSV and store it in the shell script 2) Second, pick one by one from the string list, and search a particular folder for files that... (2 Replies)
Discussion started by: vikrams
2 Replies

6. Shell Programming and Scripting

awk/sed to search & replace data in first column

Hi All, I need help in manipulating the data in first column in a file. The sample data looks like below, Mon Jul 18 00:32:52 EDT 2011,NULL,UAT Jul 19 2011,NULL,UAT 1] All field in the file are separated by "," 2] File is having weekly data extracted from database 3] For eg.... (8 Replies)
Discussion started by: gr8_usk
8 Replies

7. Shell Programming and Scripting

Using sed to search and replace data

Hi, Kindly need your expertise in this problem. I have to search and replace data. The problem is, the data is in the same format but slightly different content. What I need is sed commands that can work for those "slightly different content". input: ... (3 Replies)
Discussion started by: Alvin123
3 Replies

8. Shell Programming and Scripting

search and replace with data from another file

Can someone help me in solving the problem below. I have the following two files template_file ------------ ...other data.. ...other data.. FILE_NAME= ...other data.. ...other data.. list_file ---------- <file_name1> <file_name2> <file_name3> I need to produce another output... (3 Replies)
Discussion started by: paruthiveeran
3 Replies

9. Shell Programming and Scripting

sed - dynamic search and replace

Hi all, I have a data file formatted as in the following line: Achadd 0:35 1:35 2:35 3:40 4:40 5:40 I need the minutes converted to seconds; I wrote a script, min2sec, to do so for one datapoint. I was hoping to use sed as in the following code to call this script and... (4 Replies)
Discussion started by: x-375HK-x
4 Replies
Login or Register to Ask a Question