jeffreywhunter Posted May 14, 2018 Share Posted May 14, 2018 (edited) I'm trying to build a log file to trace my memory and see if I can track a trend where my server crashes after a couple of days. Its been mentioned to use "free -h" to create a simple track. I've used User Scripts (nice tool!) to create a cron job which works, but I'm trying to get the output readable in Windows Notepad. Pretty sure I'm dealing with an ASCII character issue for CRLF, but not been able to find an answer online (they want to use echo -e or $ or /n, which has not worked). Since almost all of our operating software today is a descendant of Unix, Mac, or MS operating SW, we are stuck with the line ending confusion - I just don't know the solution for DOS to read Linux! #!/bin/bash echo '======Start=======' >> /boot/log_free_memory.log date >> /boot/log_free_memory.log free -h >> /boot/log_free_memory.log echo '======End=======' >> /boot/log_free_memory.log The output I get does not match what I want when viewing the file in windows. However, it displays perfectly when I paste it into the code box and insert here (also displays fine if you cat the file): ======Start======= Mon May 14 14:31:04 CDT 2018 total used free shared buff/cache available Mem: 15G 3.5G 1.4G 520M 10G 10G Swap: 0B 0B 0B ======End======= And Programmers Notepad displays it correctly. So I'm missing the magic. How do I get windows editor to view the file correctly. I suppose I could just use Programmers Notepad to view log files... Suddenly dawned on me that editing config files with notepad is probably a no-no?!? ? Edited May 14, 2018 by jeffreywhunter Quote Link to comment
bonienl Posted May 14, 2018 Share Posted May 14, 2018 The easiest would be to use a true editor, like notepad++ which understands all formats. If you insist in standard notepad and MS format, change your script like this: #!/bin/bash echo '======Start=======' | todos >> /boot/log_free_memory.log date | todos >> /boot/log_free_memory.log free -h | todos >> /boot/log_free_memory.log echo '======End=======' | todos >> /boot/log_free_memory.log 1 Quote Link to comment
jeffreywhunter Posted May 14, 2018 Author Share Posted May 14, 2018 23 minutes ago, bonienl said: The easiest would be to use a true editor, like notepad++ which understands all formats. If you insist in standard notepad and MS format, change your script like this: #!/bin/bash echo '======Start=======' | todos >> /boot/log_free_memory.log date | todos >> /boot/log_free_memory.log free -h | todos >> /boot/log_free_memory.log echo '======End=======' | todos >> /boot/log_free_memory.log Thanks! I think I'll go with the easiest (and most consistent for the rest of the world!). I have programmers notepad which also works/reads the files perfectly... Quote Link to comment
pwm Posted May 14, 2018 Share Posted May 14, 2018 It's rather interesting that notepad after all these years hasn't learned that if it uses the C runtime library and opens the file in text mode, then the runtime library will normalize both Unix and Windows line breaks into just a '\n' character - so it will only be mac-specific files that will have issues since they have reversed order of carriage return and line feed. Quote Link to comment
bonienl Posted May 14, 2018 Share Posted May 14, 2018 Microsoft is excited they (finally) fixed the issue See https://blogs.msdn.microsoft.com/commandline/2018/05/08/extended-eol-in-notepad/ Quote Link to comment
pwm Posted May 14, 2018 Share Posted May 14, 2018 55 minutes ago, bonienl said: Microsoft is excited they (finally) fixed the issue Has someone really, really, important at Microsoft just died? Or how did they manage this ultimate feat of glorious high-tech coding? Quote Link to comment
CHBMB Posted May 14, 2018 Share Posted May 14, 2018 (edited) 1 hour ago, bonienl said: Microsoft is excited they (finally) fixed the issue See https://blogs.msdn.microsoft.com/commandline/2018/05/08/extended-eol-in-notepad/ 20 minutes ago, pwm said: Has someone really, really, important at Microsoft just died? Or how did they manage this ultimate feat of glorious high-tech coding? I like the fact Notepad broke Linux files, it kept things exclusive..... Edited May 14, 2018 by CHBMB Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.