Welcome to iraf.net Thursday, May 09 2024 @ 02:23 PM GMT


 Forum Index > Help Desk > Applications New Topic Post Reply
 Help with very simple scripting problem
   
Gaba_p
 04/07/2009 06:32PM (Read 1509 times)  
++++-
Regular Member

Status: offline


Registered: 10/10/2008
Posts: 104
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
...
textxand I need to create a file like this:text1 text2 text3 ... textxThanks for any help!

 
Profile Email Website
 Quote
fitz
 04/07/2009 06:32PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Assuming your file is called 'test' and you don't care whether there is a newline at the end try:[code:1:5b67f13344]cl> type test | tr STDIN "\n" " "[/code:1:5b67f13344]Otherwise, you could write a little loop:[code:1:5b67f13344]
list = "test"
while (fscan (list, line) != EOF) {
printf ("%s", line, >> "newfile")
}
print ("", >> "newfile")
[/code:1:5b67f13344]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

 
Profile Email
 Quote
   
Content generated in: 0.10 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login