How to toggle CR/LF in gnu screen?
Try stty onlcr
.
The man page says it will translate newlines to carriage return / newline pairs on output, which seems to be what you need.
using sed to change CR LF to a symbol
Try this with GNU awk:
awk -v FS='\r\n' -v OFS='|+|' -v RS='\\$\\$\\$\\$' -v ORS='\r\n' '{$1=$1}1' file
I see from your updated question that you're on Windows. To avoid ridiculous quoting rules and issues, put this in a file named "whatever.awk":
BEGIN{FS="\r\n"; OFS="|+|"; RS="\\$\\$\\$\\$"; ORS="\r\n"} {$1=$1}1
and run it as
awk -f whatever.awk file
and see if that does what you want.
Is there an easier way to send ENTER key in GNU Screen?
I always do it like this:
screen -r user -X stuff "spawn daemon^M"
where I get the ^M by hitting ctrl-v, then Enter, on the command line. In bash and vim, ctrl-v can be used to escape characters like Enter that would otherwise have a special effect.
See line breaks and carriage returns in editor
Assuming your vim settings for :set listchars=...
is set to visualize the characters you are attempting to see, in this case the carriage return characters (typed with CTL + V, CTRM + M) —— otherwise, as reported in many of the comments on this answer, the ^M character will not show on :set list
:set list
in Vim will show whitespace. End of lines show as '$
' and carriage returns usually show as '^M
'.
Writing new line character in Java that works across different OS
No. You need to pick a single file format, Windows or UNIX. Given that your customer requires notepad, you can probably pick Windows format, which means you just need "\r\n" characters. The fact that UNIX generates the file can be considered irrelevant.
Convert DOS line endings to Linux line endings in Vim
dos2unix is a commandline utility that will do this, or :%s/^M//g
will if you use Ctrl-v Ctrl-m to input the ^M, or you can :set ff=unix
and Vim will do it for you.
There is documentation on the fileformat setting, and the Vim wiki has a comprehensive page on line ending conversions.
Alternately, if you move files back and forth a lot, you might not want to convert them, but rather to do :set ff=dos
, so Vim will know it's a DOS file and use DOS conventions for line endings.
Text Editor which shows \r\n?
With Notepad++, you can show end-of-line characters. It shows CR and LF, instead of "\r" and "\n", but it gets the point across. However, it will still insert the line breaks. But you do get to see the line-ending characters.
To use Notepad++ for this, open the View menu, open the Show Symbols slide out, and select either "Show all characters" or "Show end-of-line characters".
Why does paramiko returns \r\n as newline instead of \n?
Because that is how the newlines are translated for a (pseudo)terminal. \r
is the carriage return that moves cursor to column 1, and \n
is the linefeed that moves cursor down by one.
The terminal has by default the onlcr
translation flag enabled. From stty
man pages:
[-]onlcr
newline performs a carriage return
You can also see this flag enabled, i.e. without -
in front (on the 3rd last line) in output of stty -a
.
% stty -a
speed 38400 baud; rows 46; columns 79; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
You can disable this setting with stty -onlcr
, however its presence shouldn't normally be a problem; if you suspect some binary data might become broken, you must not use a pty anyway.
If this is just some single command, then it does not add much to security that you send your plaintext password over SSH; if anyone haves access to your remote account now they'll not only have unlimited access to root on that computer, but they'd also know your password. It is better to let ssh to root, and let root run this 1 command with "forced commands", or edit /etc/sudoers
so that no password is required for this single command from this account.
Related Topics
How to Run the Cron Job as a User Instead of Root User
Behavior of Cd/Bash on Symbolic Links
Bash: Delete Based on File Date Stamp
Is It Necessary to Deregister a Socket from Epoll Before Closing It
Fallocate() Command Equivalent in Os X
Error: Clgetplatformids -1001 When Running Opencl Code (Linux)
Use Crontab Job Send Mail, the Email Text Turns to an Attached File Which Named Att00001.Bin
Release of Flock in Case of Errors
Why File Is Accessible After Deleting in Unix
How to Install a Rpm Package and Its Dependencies Offline
Cuda Performance Penalty When Running in Windows
How to Install Influxdb in Windows