Parsing text from a linux log on windows (Adding spaces that are removed) - windows

So I do a little work from time to time on Linux and today I needed to document some text files copied from the terminal window. The only problem was that I brought a linux text file over to notepad on my Win7 comp, and I noticed that all the carriage returns were removed from the text.
Is there any way to quickly add the carriage returns back in?

You can do the conversion before the transfer:
unix2dos -o <pattern>
In case you need to keep the old files or you have only read access to them:
unix2dos -n <original-file> <converted-file>
You might not have this utility available by default in your linux distro in which case you will need to install the tofrodos package.

Use Notepad++ instead of Notepad. It's free and it has a lot of functionality, including proper handling of EOL marks.

Related

use Ubuntu at virtual box based on windows 7 cannot edit text

I have a problem that
1. my laptop is X86 win7 & install a virtual box.
2. Based on virtual box, I installed a Ubuntu.
Now I share a folder between win7 & Ubuntu.
And edit a bash file on windows by, ex UltraEdit.
After then, when I run the bash on Ubuntu.
It said:
mkdir: cannot create directory ‘dvbpsi\r’: Protocol error
cp: cannot stat 'src/table/.h': No such file or directory*
It seems that \r is wrong.
Instead, if I tried to store in virtual box, it shows the wrong msg below:
It seems that I CANNOT store anything from virtual OS to a shared folder.
Is there a smart way to resolve it?
Thanks in advance!!
UltraEdit can create, edit and save text files with DOS (\r\n) or UNIX (just \n) or MAC (just \r) line terminators.
The line terminator type is indicated for active file in status bar at bottom of UltraEdit main window.
The conversion between the various line terminator types can be done at any time in UltraEdit using for example the DOS to UNIX conversion command or on using Line terminator option in Save As dialog.
The default line ending type for new files can be also configured in configuration at
Advanced - Settings/Configuration - File Handling - DOS/Unix/Mac Handling.
I suggest following configuration settings for using UltraEdit mainly for editing Windows text files and only sometimes for Unix shell scripts:
Default file type for new files ... DOS
Unix/Mac file detection/conversion ... Automatically convert to DOS format
Only recognize DOS terminated lines (CR/LF) as new lines for editing ... not checked
Save file as input format (Unix/Mac/DOS) ... checked
Status bar shows original line terminator format (on disk) ... checked
So creating/editing shell scripts on Windows with UNIX type of line termination is easy using UltraEdit on Windows being also available for Linux and Mac.

Converting a Windows .cpp file for Unix system?

I have a .cpp file that I wrote on my Windows 8 computer and I am trying to paste its code into my schools Unix based system via Putty SSH client. The editor that is used on the Unix machines is the Vi editor. When I copy all the code from my .cpp file in my Windows computer and right click on the Vi editor and paste, the code shows up but its all over place and I can't even read it(I am pretty sure it wouldn't compile either). Is there a way to fix it so the code maintains its formatting in the Vi editor ? Thanks for any help !
There is usually a unix utility called dos2unix and one called unix2dos which will convert your file to dos or unix format.
If you have those it should just be a matter of:
dos2unix myfile.cpp myfile.cpp
Also, instead of pasting it into your editor try using pscp to copy the file to your target machine.
pscp myfile myname#hostname:/mydirectory/myfile
I think you must be getting beaten by the difference in the line endings of windows and unix.
You can try using editor like Notepad++ and save the file on windows.
Open the file in Noteapd++ and Edit -> EOL Conversion -> UNIX Format and save

Vim. Troubles with encoding on file saved in windows

I have ��� chars after each time I save file in windows for some folders. And for some other folders - all is fine. I can't find difference between folders where everything is fine and folders where files saving with bad endings. So I have to run dos2unix in my linux virtual machine on modified files every time. Since these files is javascript - it's very annoying!
Help me, where to dig? How to avoid appearing of ��� chars at the end of file?
:set fileencoding=utf-8 does not help.
Usually vim has for dos files - [dos] label at the bottom of buffer window - in my case all is fine, and no [dos] label there.
This looks more like a file format problem than encoding. I recommend adding this to your ~/_vimrc:
set fileformat=unix
set fileformats=unix,dos
set nobinary
You can find more details in :help fileformat

When to use .exe and when not?

I dont really understand whats going on and cant see the difference:
I'm downloaded the base64.exe for creating base64 text under windows. i copied it to C:\Windows\ because its in the %PATH% variable.
Now i want to try it: echo Hello | base64 works great. Okay i dont need to append .exe and as far as i know i dont need to do it also with .bat and .com files.
But now i have some cygwin tools installed and for example tried which base64, which doesnt work, because it says that base64 is not in path. Then i typed in which base64.exe and got C:\Windows.
So my question is now: when i need to use .exe and when i dont? Is it only when i'm using cygwin tools that i need to append .exe?
Cygwin is a shell which emulates UNIX behaviour. UNIX doesn't know anything about .exe, thats why Cygwin can't find base64.exe. Under UNIX, binaries are stored without an extionsion added to their filename, e.g. just base64.
Windows CMD automatically appends .bat, .com, .exe and the like to your file names. Cygwin does not. So if you are using a linux shell you have to append it manually.
Since Cygwin is aware that it always runs under Windows it might append .exe if you want to perform certain actions in the shell itself (e.g. opening a file), to behave more friendyl to Windows users who expect this behaviour. However programs running under Cygwin might not integrate those features since they were mainly devoloped for usage under UNIX. That could be a reason why which base64 fails.

How to use Windows Emacs as an SVN client?

I just installed svn client from tigris and from the command line I can do checkouts, commits merges etc.
But now I would like to use emacs for merging files or directories.
vc-merge only works when you're in a file. I can't get it to work on a directory.
There is also the command line utility and for that I would like to use the same emacs session I'm using for my (dos) shell.
From the documentation I found I need to set SVN_EDITOR to:
gnuclient, emacsclient but that doesnt work either (hitting 'e' after finding conflicts reports emacsclient/gnuclient is not recognized as external editor). Putting c:\programs\emacs-23.3\bin\runemacs.exe starts a whole new emacs frame, and it doesn't show me the nice diff screen with the two conflicting files, I remember seeing when working with cvs and emacs.
I don't use the same OS as you do, but for the SVN_EDITOR part, I think what you want is emacsclientw and not emacsclient, take a look at the binaries in c:\programs\emacs-23.3\bin\. You also probably need an emacs started in server mode, the function is named server-start.

Resources