How do I get the `tr` command to ignore newlines?


Rihiag

I want to replace multiple spaces with one space. I am doing trthis. But this also replaces newlines with spaces. How can I avoid it?

Code:

tr -s [:space:] ' '

enter:

He  llo
Wor  ld
how  are  you

Requested output:

He llo
Wor ld
how are you

my output:

He llo Wor ld how are you
Mike Scott

:space:Match horizontal and vertical whitespace. Use :blank:instead of just matching horizontal whitespace.

Related


How do I get the `tr` command to ignore newlines?

Rihiag I want to replace multiple spaces with one space. I am doing trthis. But this also replaces newlines with spaces. How can I avoid it? Code: tr -s [:space:] ' ' enter: He llo Wor ld how are you Requested output: He llo Wor ld how are you my output

How do I get Cj to send newlines in the tmux command line?

Sam I'm already a big fan of using C-jinstead of <ENTER>sending newlines. Unfortunately, in the tmux command line ( which is invoked by prefix-:default ) C-j, even set -gw status-keys emacsputting in does nothing ~/.tmux.conf. (Note that it C-jsends newlines f

How do I get Cj to send newlines in the tmux command line?

Sam I'm already a big fan of using C-jinstead of <ENTER>sending newlines. Unfortunately, in the tmux command line ( which is invoked by prefix-:default ) C-j, even set -gw status-keys emacsputting in does nothing ~/.tmux.conf. (Note that it C-jsends newlines f

When passing stdout into Perl, how do I get it to print newlines?

tom I just discovered a way to pass stdout to Perl, and I'm surprised it's even possible to do this: [user@folder] $ echo print 1/3 | perl 0.33333[user@folder] $ From what I understand, you are putting the print command into Perl, and using Perl's code for fl

When passing stdout into Perl, how do I get it to print newlines?

tom I just discovered a way to pass stdout to Perl and I'm surprised you can even do this: [user@folder] $ echo print 1/3 | perl 0.33333[user@folder] $ From what I understand, you are putting the print command into Perl, and using Perl's code for floating poi

When passing stdout into Perl, how do I get it to print newlines?

tom I just discovered a way to pass stdout to Perl and I'm surprised you can even do this: [user@folder] $ echo print 1/3 | perl 0.33333[user@folder] $ From what I understand, you are putting the print command into Perl, and using Perl's code for floating poi

How do I get bash to give Windows newlines related errors?

Hawkeye Suppose I have the following shell script: #!/bin/bash \n echo "Hello World" \n running it gives Hello world. Now suppose I have the following shell script #!/bin/bash \r\n echo "Hello world" \r\n Running it gives the result: bad interpreter: No su

How to ignore newlines at the end of openssl md5 command line?

Kevin Bear I know we can get the correct output by: echo -n 123456 | openssl md5 e10adc3949ba59abbe56e057f20f883e or printf 123456 | openssl md5 e10adc3949ba59abbe56e057f20f883e or printf 123456 > file.txt openssl md5 file.txt e10adc3949ba59abbe56e057f20f883e

How do i get into the value inside the html <tr> object

Robel Haile So I have this code. I want to send data from html input to controller parameter. In my jquery I have a line that looks like this var currentRow = $(this).closest("tr"); but I don't know how to get into the value of each input inside the currentRow

How should I use fgetc to ignore newlines in stdin?

Philip N I'm having trouble filling a fixed size 2D array with a fgetc()function . My program should be read only '-'or the characters entered in a row must be equal to the size of the column '+'.'!' Here is the problematic part of my code: for(i = 0; i < rows

How should I use fgetc to ignore newlines in stdin?

Philip N I'm having trouble filling a fixed size 2D array with a fgetc()function . My program should be read only '-'or the characters entered in a row must be equal to the size of the column '+'.'!' Here is the problematic part of my code: for(i = 0; i < rows

How do I get the "clear" command in Cygwin?

MarnixKlooster restores Monica I installed Cygwin with a fairly small selection of packages. In the terminal, I try to do a "clear" to clear the terminal, but I get bash: clear: command not found How do I work? MarnixKlooster restores Monica Install the Cygwi

How do I get the command executed by Bazel

Guy Coding I'm wondering if there is a way to make Bazel list, output, display, etc. all commands that can be executed from the command line that can be run during a clean build. I don't care if the output is on the screen or in a file, etc. If necessary, I ma

How do I get the command executed by Bazel

Guy Coding I'm wondering if there is a way to make Bazel list, output, display, etc. all commands that can be executed from the command line that can be run during a clean build. I don't care if the output is on the screen or in a file, etc. If necessary, I ma

How do I get the "clear" command in Cygwin?

MarnixKlooster restores Monica I installed Cygwin with a fairly small selection of packages. In the terminal, I try to do a "clear" to clear the terminal, but I get bash: clear: command not found How do I work? MarnixKlooster restores Monica Install the Cygwi

How do I get the command executed by Bazel

Guy Coding I'm wondering if there is a way to make Bazel list, output, display, etc. all commands that can be executed from the command line that can be run during a clean build. I don't care if the output is on the screen or in a file, etc. If necessary, I ma

How do I get C:/ on the command line

username I am on Windows 10. I'm trying to load Adobe Dreamweaver extension via command line on Windows. I want to navigate to C:\Program Files\Adobe\Adobe Extension Manager CSx\ I am following the instructions here . If I select command prompt (admin), I getC

How do I get the "clear" command in Cygwin?

MarnixKlooster restores Monica I installed Cygwin with a fairly small selection of packages. In the terminal, I try to do a "clear" to clear the terminal, but I get bash: clear: command not found How do I work? MarnixKlooster restores Monica Install the Cygwi

How do I get the command executed by Bazel

Guy Coding I'm wondering if there is a way to make Bazel list, output, display, etc. all commands that can be executed from the command line that can be run during a clean build. I don't care if the output is on the screen or in a file, etc. If necessary, I ma

How do I get the command executed by Bazel

Guy Coding I'm wondering if there is a way to make Bazel list, output, display, etc. all commands that can be executed from the command line that can be run during a clean build. I don't care if the output is on the screen or in a file, etc. If necessary, I ma

How do I get C:/ on the command line

username I am on Windows 10. I'm trying to load Adobe Dreamweaver extension via command line on Windows. I want to navigate to C:\Program Files\Adobe\Adobe Extension Manager CSx\ I am following the instructions here . If I select command prompt (admin), I getC

How do I get ASAN to ignore child processes?

username I'm trying to run my app with ASAN enabled to search for leaks and other errors, however, since I'm using popen inside the app, the sanitizer also seems to report subprocess errors (I don't really care and it's annoying Puzzled. ). Is there a way to m

How do I get IntelliJ to ignore Subversion's formatting?

cbmeeks I am using IntelliJ 12 Ultimate. Every developer on our team likes to have their own spacing (2 characters, 4 characters, tabs, etc). I have this habit of pressing many times ALT SHIFT Fwhile writing code . I like the way it formats the code. However,

How do I get ASAN to ignore child processes?

username I'm trying to run my app with ASAN enabled to search for leaks and other errors, however, since I'm using popen inside the app, the sanitizer also seems to report subprocess errors (I don't really care and it's annoying Puzzled. ). Is there a way to m

How do I get tmux to ignore commands when in a Neovim pane?

pristine rock I'm trying to get my tmux and neovim to work together as seamlessly as possible. However, I have a question. Whenever I'm in a neovim pane in tmux, I want to split the neovim into horizontal/vertical windows using the default desired bindings...

How do I expect newlines in Expect scripts?

x-yuri Consider the following interactive script: #!/usr/bin/env bash set -eu while true; do read -p '> ' if [ "$REPLY" == quit ]; then break fi echo "'$REPLY'" done Now, I want expectto interact with: #!/usr/bin/env bash set -eu echo

How do I expect newlines in Expect scripts?

x-yuri Consider the following interactive script: #!/usr/bin/env bash set -eu while true; do read -p '> ' if [ "$REPLY" == quit ]; then break fi echo "'$REPLY'" done Now, I want expectto interact with: #!/usr/bin/env bash set -eu echo

How do I expect newlines in Expect scripts?

x-yuri Consider the following interactive script: #!/usr/bin/env bash set -eu while true; do read -p '> ' if [ "$REPLY" == quit ]; then break fi echo "'$REPLY'" done Now, I want expectto interact with: #!/usr/bin/env bash set -eu echo