Dman33
09-29-2004, 02:13 PM
Okay, I have not written a shell script in like 8 years, so I am trying to recall how to complete a simple task. I need to write a script that will have two arguments, file1 and file2. Both files are simple text files. We will assume that I already set up the argument error-checking. I need to open file1 and read each line in it, writing each line to file2 substituting all carriage returns with commas.
For example, file1 is:
red
yellow
blue
I want to create file2 which will be:
red,yellow,blue
There might be a simple 2-liner which will involve using awk but I cannot come up with how. Now, I can come up with some clumsy ways to do this in C++ or something, and I could whip this up in 2 minutes using VBScript or KixStart but I need it in shell script. Any ideas?
Meanwhile I will be dusting my old books from college off... :dead:
For example, file1 is:
red
yellow
blue
I want to create file2 which will be:
red,yellow,blue
There might be a simple 2-liner which will involve using awk but I cannot come up with how. Now, I can come up with some clumsy ways to do this in C++ or something, and I could whip this up in 2 minutes using VBScript or KixStart but I need it in shell script. Any ideas?
Meanwhile I will be dusting my old books from college off... :dead: