newline

What are the differences in echo between zsh and bash?

喜夏-厌秋 提交于 2021-01-28 10:56:20
问题 In bash, in this specific case, echo behaves like so: $ bash -c 'echo "a\nb"' a\nb but in zsh the same thing turns out very differently...: $ zsh -c 'echo "a\nb"' a b and fwiw in fish, because I was curious: $ fish -c 'echo "a\nb"' a\nb I did realize that I can run: $ zsh -c 'echo -E "a\nb"' a\nb But now I am worried that I'm about to stumble into more gotchas on such a basic operation. (Thus my investigation into fish: if I'm going to have to make changes at such a low level for zsh, why not

What are the differences in echo between zsh and bash?

风流意气都作罢 提交于 2021-01-28 10:50:51
问题 In bash, in this specific case, echo behaves like so: $ bash -c 'echo "a\nb"' a\nb but in zsh the same thing turns out very differently...: $ zsh -c 'echo "a\nb"' a b and fwiw in fish, because I was curious: $ fish -c 'echo "a\nb"' a\nb I did realize that I can run: $ zsh -c 'echo -E "a\nb"' a\nb But now I am worried that I'm about to stumble into more gotchas on such a basic operation. (Thus my investigation into fish: if I'm going to have to make changes at such a low level for zsh, why not

What are the differences in echo between zsh and bash?

余生长醉 提交于 2021-01-28 10:50:46
问题 In bash, in this specific case, echo behaves like so: $ bash -c 'echo "a\nb"' a\nb but in zsh the same thing turns out very differently...: $ zsh -c 'echo "a\nb"' a b and fwiw in fish, because I was curious: $ fish -c 'echo "a\nb"' a\nb I did realize that I can run: $ zsh -c 'echo -E "a\nb"' a\nb But now I am worried that I'm about to stumble into more gotchas on such a basic operation. (Thus my investigation into fish: if I'm going to have to make changes at such a low level for zsh, why not

How to correctly download files using ftplib so line breaks are added for windows

别等时光非礼了梦想. 提交于 2021-01-28 08:10:07
问题 I have been using a very simple batch file to download millions of files from a UNIX ftp server for years login passwd ascii prompt n cd to the right directory get some_file get another_file cd to the next directory repeat the pattern The nice thing about this was that it was simple and all the files arrived with Window's line breaks so the files were ready to use with my existing programs. Because of some changes in my router I had to write a Python script to pull the files - my first

^M characters in exported file, converting to newlines

大憨熊 提交于 2021-01-27 07:03:02
问题 I exported a CSV from excel to parse using python. When I opened the vimmed the CSV, I noticed that it was all one line with ^M characters where newlines should be. Name, Value, Value2, OtherStuff ^M Name, Value, Value2, OtherStuff ^M I have the file parsed such that I modify the values and put the into a string (using 'rU' mode in csvreader). However, the string has no newlines. So I am wondering, is there a way to split the string on this ^M character, or a way to replace it with a \n? 回答1:

^M characters in exported file, converting to newlines

為{幸葍}努か 提交于 2021-01-27 07:00:50
问题 I exported a CSV from excel to parse using python. When I opened the vimmed the CSV, I noticed that it was all one line with ^M characters where newlines should be. Name, Value, Value2, OtherStuff ^M Name, Value, Value2, OtherStuff ^M I have the file parsed such that I modify the values and put the into a string (using 'rU' mode in csvreader). However, the string has no newlines. So I am wondering, is there a way to split the string on this ^M character, or a way to replace it with a \n? 回答1:

Why does LF and CRLF behave differently with /^\s*$/gm regex?

廉价感情. 提交于 2021-01-24 09:45:08
问题 I've been seeing this issue on Windows. When I try to clear any whitespace on each line on Unix: const input = `=== HELLO WOLRD ===` console.log(input.replace(/^\s+$/gm, '')) This produces what I expect: === HELLO WOLRD === i.e. if there were spaces on blank lines, they'd get removed. On the other hand, on Windows, the regex clears the WHOLE string. To illustrate: const input = `=== HELLO WOLRD ===`.replace(/\r?\n/g, '\r\n') console.log(input.replace(/^\s+$/gm, '')) (template literals will

Do I really need to specify all binary files in .gitattributes

喜夏-厌秋 提交于 2021-01-21 09:22:07
问题 I've read Git documentation that shows that I can explicitly set certain files to be treated as text, so their line endings are automatically changed or as binary to ensure that they are untouched. However, I have also read that Git is pretty good at detecting binary files, which makes me thing this is not needed. So my question is do I really need to specify these explicit settings for every single file extension in my repository? I've seen some recommend to do so for all image file

System new line separator in Ruby

余生颓废 提交于 2021-01-20 04:23:40
问题 How can I determine new line separator used by OS (LF, CR/LF or other), in Ruby? 回答1: Not sure if there is a direct solution to get the type of newline based on OS, but there is the $/ variable that holds the "input record separator". By default this will be "\n". (Documentation here) You can detect the OS and then set $/ to the "correct" value. To detect OS: puts RUBY_PLATFORM # => 'i386-linux' require 'rbconfig' puts Config::CONFIG['target_cpu'] # => 'i386' puts Config::CONFIG['target_os']

System new line separator in Ruby

a 夏天 提交于 2021-01-20 04:21:26
问题 How can I determine new line separator used by OS (LF, CR/LF or other), in Ruby? 回答1: Not sure if there is a direct solution to get the type of newline based on OS, but there is the $/ variable that holds the "input record separator". By default this will be "\n". (Documentation here) You can detect the OS and then set $/ to the "correct" value. To detect OS: puts RUBY_PLATFORM # => 'i386-linux' require 'rbconfig' puts Config::CONFIG['target_cpu'] # => 'i386' puts Config::CONFIG['target_os']