View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Help with very simple scripting problem

Gabriel wrote on Apr 07, 2009

Hi,

I'm trying to do something very simple, but I can't figure out how to. I have a file like this:

text1
text2
text3
...
textx

and I need to create a file like this:

text1 text2 text3 ... textx

Thanks for any help!

Mike Fitzpatrick wrote on Apr 07, 2009

Assuming your file is called 'test' and you don't care whether there is a newline at the end try:

cl> type test | tr STDIN "\n" " "


Otherwise, you could write a little loop:


list = "test"
while (fscan (list, line) != EOF) {
    printf ("%s", line, >> "newfile")
}
print ("", >> "newfile")


This will create the new file called 'newfile' with a terminating newline. You could similarly redirect using the one-liner above and then add a newline the same way.

-Mike

Last post on Apr 07, 2009