vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I'm try to format some files to use as input for a sqlplus command. The file is nothing but a list of numbers, one per line. I need to place a comma at the end of each line, but I'm not having any luck. My file looks something like this: 123456 112233 1789077 456786755 The number could be of varying lenghts, but only one number per line. what I want is something like this: 1234566, 2343535544, 234678, |
| |||
| Here are a simple script: #!/bin/ksh cat file.txt | awk -F: {'print $1","}' > file1.txt Kruno "Tony" <zahst@yahoo.com> wrote in message news:fd6e5055.0410050626.2beee183@posting.google.c om... > I'm try to format some files to use as input for a sqlplus command. > The file is nothing but a list of numbers, one per line. I need to > place a comma at the end of each line, but I'm not having any luck. > > My file looks something like this: > > 123456 > 112233 > 1789077 > 456786755 > > The number could be of varying lenghts, but only one number per line. > what I want is something like this: > > 1234566, > 2343535544, > 234678, |
| |||
| Kruno <krunok@rocketmail.com> wrote: > Here are a simple script: > > #!/bin/ksh > > cat file.txt | awk -F: {'print $1","}' > file1.txt > > Kruno > > "Tony" <zahst@yahoo.com> wrote in message > news:fd6e5055.0410050626.2beee183@posting.google.c om... >> I'm try to format some files to use as input for a sqlplus command. >> The file is nothing but a list of numbers, one per line. I need to >> place a comma at the end of each line, but I'm not having any luck. >> >> My file looks something like this: >> >> 123456 >> 112233 >> 1789077 >> 456786755 >> >> The number could be of varying lenghts, but only one number per line. >> what I want is something like this: >> >> 1234566, >> 2343535544, >> 234678, This works, but classifies for the Useless Use of cat Award. Can do it with one process, and I think sed is somewhat faster than awk: sed -e 's/$/,/' file.txt > file1.txt HTH, Erik |
| |||
| news@elaan.dds.nl wrote: > Kruno <krunok@rocketmail.com> wrote: >> Here are a simple script: >> >> #!/bin/ksh >> >> cat file.txt | awk -F: {'print $1","}' > file1.txt >> >> Kruno >> >> "Tony" <zahst@yahoo.com> wrote in message >> news:fd6e5055.0410050626.2beee183@posting.google.c om... >>> I'm try to format some files to use as input for a sqlplus command. >>> The file is nothing but a list of numbers, one per line. I need to >>> place a comma at the end of each line, but I'm not having any luck. >>> >>> My file looks something like this: >>> >>> 123456 >>> 112233 >>> 1789077 >>> 456786755 >>> >>> The number could be of varying lenghts, but only one number per line. >>> what I want is something like this: >>> >>> 1234566, >>> 2343535544, >>> 234678, > > This works, but classifies for the Useless Use of cat Award. Can > do it with one process, and I think sed is somewhat faster than > awk: > > sed -e 's/$/,/' file.txt > file1.txt > > HTH, Erik Or, in ksh only: while read line ; do echo "$line," done < file >file1 Or, to make cat less useless: #!/bin/ksh cat $* | while read line ; do echo "$line," done (script accepts arguments or stdin) -- (c) ljm ( xs4all) No part of this copyright message may be reproduced, read or seen, dead or alive or by any means, including but not limited to telepathy without the benevolence of the author. |
| |||
| "Tony" <zahst@yahoo.com> wrote in message news:fd6e5055.0410050626.2beee183@posting.google.c om... > I'm try to format some files to use as input for a sqlplus command. > The file is nothing but a list of numbers, one per line. I need to > place a comma at the end of each line, but I'm not having any luck. > > My file looks something like this: > > 123456 > 112233 > 1789077 > 456786755 > > The number could be of varying lenghts, but only one number per line. > what I want is something like this: > > 1234566, > 2343535544, > 234678, You don't mention how many files or how big. If I make the assumption you can edit the file with vi. In command mode :%s/$/,/g save the file and you are done. Doug |
| ||||
| zahst@yahoo.com (Tony) wrote in message news:<fd6e5055.0410050626.2beee183@posting.google. com>... > I'm try to format some files to use as input for a sqlplus command. > The file is nothing but a list of numbers, one per line. I need to > place a comma at the end of each line, but I'm not having any luck. > > My file looks something like this: > > 123456 > 112233 > 1789077 > 456786755 > > The number could be of varying lenghts, but only one number per line. > what I want is something like this: > > 1234566, > 2343535544, > 234678, vi the file and do ":1,$s/$/\,/g" then ":wq!" |