dateez
April 11, 2009, 3:37am
1
Hi,
I'm reading and writing a line from one file to another.
Input line is like this:
My name is David. Working on a shell script now.
When I use "echo" or "print" output comes like this,
My name is David. Working on a shell script now.
Sample Code:
while read LINE
do
echo $LINE > $outfile1
print $LINE > $outfile2
done < $inputfile
I need to write the line as it is, without any modification, even with the spaces.
Is there any other way to accomplish this? Please let me know. Thanks in advance.
sauron
April 11, 2009, 5:36am
2
Hi,
doing it your way gives you errors?
I'm not sure i understood the problem, can you explain what happens if you use that while cicle?
I think it should work correctly
bye
cp $inputfile $outputfile1
cp $inputfile $outputfile2
will do what you want or have I missed something from your requirements?
dateez
April 12, 2009, 10:05am
4
here is my problem, all my spaces are being ate up by echo or print,
Input line:
My(5 spaces)name(5 spaces)is(5 spaces)David.(5 spaces)Working(5 spaces)on(5 spaces)shell(5 spaces)scripting(5 spaces)now.
Output line:
My(1 space)name(1 space)is(1 space)David.(1 space)Working(1 space)on(1 space)Shell(1 space)scripting(1 space)now.
i think it explains my problem now..
dateez
April 12, 2009, 10:06am
5
Hi Tony,
Thank u for ur reply, hope i'm clear with my problem here!!!
dateez:
Input line:
My(5 spaces)name(5 spaces)is(5 spaces)David.(5 spaces)Working(5 spaces)on(5 spaces)shell(5 spaces)scripting(5 spaces)now.
Output line:
My(1 space)name(1 space)is(1 space)David.(1 space)Working(1 space)on(1 space)Shell(1 space)scripting(1 space)now.
First you have to learn to use the code tags when you post your data sample.
Learn howto use double quote to preserve spacing, see below:
# cat file
My name is David. Working on shell scripting now.
# while read LINE
do
echo $LINE
echo "$LINE"
done < file
My name is David. Working on shell scripting now.
My name is David. Working on shell scripting now.
dateez
April 12, 2009, 6:45pm
7
hi,
ur suggestion worked like charm.... thank u.... n i read the code tags.... i'll try to be more clear n formatted next time....
.. and please read and understand the Forum Rules :rolleyes: