Tag Info

Hot answers tagged

20

Or does it know when its output is being piped to another command, and format its output differently in this case? Yes. From the full manual (available through info ls if the documentation is installed): If standard output is a terminal, the output is in columns (sorted vertically) and control characters are output as question marks; otherwise, ...


20

The convention for Unix text files is that every line is terminated by a newline, and that newlines are line terminators, not line separators. When Vim saves a buffer as a file, it terminates every line with the end-of-line sequence for that file format, which for Unix is a newline. See :help 'fileformat' If you're using Unix text-processing tools, it's ...


17

There is: dos2unix


15

Here's a way that utilizes bash parameter expansion and its IFS special variable. $ System=('s1' 's2' 's3' 's4 4 4') $ ( IFS=$'\n'; echo "${System[*]}" ) We use a subshell to avoid overwriting the value of IFS in the current environment. In that subshell, we then modify the value of IFS so that the first character is a newline (using $'...' quoting). ...


11

In recent versions of Vim there's a 'listchars' setting that lets you specify which characters should be used for the EOL and TAB characters, and for trailing spaces. You could: set listchars=eol:$,tab:\[SPACE]\[SPACE] ...to display eol chars specially without collapsing tabs (type a space character, not [,S,P,A,...). I don't know of anything ...


11

You could install pcregrep (available in most distro repositories) - which is grep using the pcre library, which does "Perl Compatible Regular Expressions". It has a command line option -M which allows you to do multiline searches - from the man page: "The output for any one match may consist of more than one line." So you could do pcregrep -M ...


10

I remember that Macs always used to use CR despite Unix using LF and Windows using CR+LF Your memory is from the good old times though: Mac OS X, as POSIX-compliant Unix uses the typical Unix LF. CR is a relict from the "classic" Mac OS, it's not used anymore. For example, check the manpage of unix2dos (emphasis mine): In DOS/Windows text files a ...


10

The new line character with the echo command is "\n". Taking the following example: echo -e "This is line 1\nThis is line 2" Would result in the output This is line 1 This is line 2 The "-e" parameter is important here.


10

You can use printf to print each array item on its own line: $ System=('s1' 's2' 's3' 's4 4 4') $ printf "%s\n" "${System[@]}" s1 s2 s3 s4 4 4


10

This happens when the EOL control characters are not correct. Windows represents newlines with the carriage return + line feed. In Notepad++, you can check for these characters by selecting: View > Show Symbols > [x] Show End of Line You need to modify your script so your data is formatted like this:


9

ls detects it when you pipe its output. You can see it in the documentation: If standard output is a terminal, the output is in columns (sorted vertically) and control characters are output as question marks; otherwise, the output is listed one per line and control characters are output as-is. If you want each file in the output to be placed on a ...


8

I think \n moves the needle down, and \r moves the needle to the beginning of a line (left align)? I'm not sure, though This is true, more or less, but mostly a historical curiosity. Originally, linefeed (LF) was used to advance the paper by one line on printers and hardcopy terminals (teleprinters); carriage return (CR) returned the print head to the ...


8

The correct way to print is echo "$ifc"


8

Use the "Extended" setting in the Replace window (not "Regular expression": I'm sure there's a way to do it with Regular expression, but using "Extended" works fine). Enter ".pPrev.\r\n" in the "Find what" field, and leave the "Replace what" field blank. This will include the \r\n characters in the match and delete the whole line.


7

I think this does what you want: make sure there is an empty line at the end of the file, then join every paragraph (terminated by an empty line). G:a . :g/^./ .,/^$/-1 join Explanation: first go to the end of the file and append an extra empty line with :a (maybe there's a more elegant way to do that; interactively, you can replace the first three lines ...


6

According to Helixoft: Multiline Search and Replace in Visual Studio you can enable Regular Expressions and then use \n to indicate a new line.


6

Go to Find (Ctrl + F) -> tab Replace -> click More... -> Special -> End of paragraph. The symbol is ^p. You can use it in both directions. I have MS Office 2007, but it should work in older versions too.


6

CR and LF The American Standard Code for Information Interchange (ASCII) defined control-characters including CARRIAGE-RETURN (CR) and LINE-FEED (LF) that were (and still are) used to control the print-position on printers in a way analogous to the mechanical typewriters that preceded early computer printers. Platform dependency In Windows the traditional ...


5

Use the ^ character as an escape: command -option:text^ whatever I'm assuming you're using cmd.exe from Windows XP or similar. This is not actual DOS. If you are using actual DOS (MS-DOS, Win3.1, Win95, Win98, WinME), then I do not believe there is an escape for newlines. You would need to run a custom shell. cmd.exe will prompt you for "More?" ...


5

reopen DOS-formated text file in UNIX formart: :e ++ff=unix you will see ^M(\r) at the end of line. if you want display ^M in hex: :set dy=uhex


4

Notepad++ Press Ctrl + H. Use the following settings: Find what: ; (with one trailing space) Replace with: \r\n Search Mode: Extended Wrap around: checked Click Replace All. \r\n symbolizes a Windows newline, i.e., carriage return character followed by a linefeed character. Word 2010 Press Ctrl + H. Use the following settings: Find ...


3

I belive this should work : alias cwd="echo -n `pwd` | pbcopy; echo \"Copied `pwd`\"" The -n says "no new line". Either that or you can always pass the output through tr and remove the new line character like that: alias cwd="echo `pwd` | tr -d "\n" | pbcopy; echo \"Copied `pwd`\"" I'm not sure if you want to remove the trailing new line char from the ...


3

On Ubuntu: $ apt-get install dos2unix $ unix2dos file.txt On Windows: Download and extract dos2unix from http://waterlan.home.xs4all.nl/dos2unix.html (the Windows 32-bit version or the Windows 64-bit version) On the command prompt, enter dos2unix-<something>\bin\unix2dos.exe file.txt


3

You can do it like this. rm -f file for i in ${ActiveIPs} do echo ${i} >> file done


3

One-liner: printf "%s\n" $ActiveIPs > ActiveIPs.txt This behaves as follows: $ActiveIPs is expanded by the shell. word splitting breaks it at whitespace characters. The pieces are passed to printf as individual parameters. If it were quoted as in printf "%s\n" "$ActiveIPs", it would not be split, and it would be passed to printf as a single ...


3

You will have to press Enter after the last line. That extra blank line in Notepad++ is just visible in the editor. It isn't really putting any data in the output file. (Besides the EOL character that you want.) P.S. It doesn't matter whether you use Windows, Unix or Mac line-endings. The behavior of Notepad++ is the same for all three. You will have to add ...


3

I don't think Emacs's behavior can be changed in the way you want. Have you thought about using regexp-replace instead? That way you could see your new lines as \n.


3

You can do this with either perl or sed using: perl -pe 's/\r?\n|\r/\r\n/g' inputfile > outputfile # Convert to DOS perl -pe 's/\r?\n|\r/\n/g' inputfile > outputfile # Convert to UNIX sed -e 's/$/\r/' inputfile > outputfile # UNIX to DOS (adding CRs on Linux based OS that use GNU extensions) sed -e 's/\r$//' inputfile > ...


3

It looks like char(10) actually did the trick, but it's just not visible in the sheet. When the data from the spreadsheet is used in a mail merge later (for address labels), the newline is there!



Only top voted, non community-wiki answers of a minimum length are eligible