newline

replace two newlines to one in shell command line

自闭症网瘾萝莉.ら 提交于 2019-12-10 10:43:51
问题 There are lot of questions about replacing multi-newlines to one newline but no one is working for me. I have a file: first line second line MARKER third line MARKER other lines many other lines I need to replace two newlines (if they exist) after MARKER to one newline. A result file should be: first line second line MARKER third line MARKER other lines many other lines I tried sed ':a;N;$!ba;s/MARKER\n\n/MARKER\n/g' Fail. sed is useful for single line replacements but has problems with

Remove new line / line break characters only for specific lines

霸气de小男生 提交于 2019-12-10 10:26:41
问题 I have the following output: 02:01:31 OFFLINE 02:02:31 ONLINE and I would like it to become: 02:01:31 OFFLINE 02:02:31 ONLINE I found a way of removing all newline / line breaks with sed ':a;N;$!ba;s/\n/ /g' however it gives me what follows which is not really what I'm after: 02:01:31 OFFLINE 02:02:31 ONLINE Q: How can I remove newline / line breaks only for lines that match a certain pattern (in this case [0-9] would be enough? PS: It doesn't have to be with sed as long as I can apply a

Power BI (Power Query) Web request results in “CR must be followed by LF” Error

六月ゝ 毕业季﹏ 提交于 2019-12-10 06:10:18
问题 When you use the Web.Page(Web.Contents('url')) function to read a table from a web page, some sites will cause an error due to inconsistent linefeeds. DataSource.Error: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF There doesn't appear to be any option you can pass to the Web functions to ignore those errors. This method works for a short while, but doesn't survive a save/refresh: let BufferedBinary = Binary.Buffer(Web.Contents("http://vote

Print a carriage return in java on windows on console

Deadly 提交于 2019-12-10 01:56:50
问题 On my OS X machine, the following line gives me a nice and easy way to track the state of my loops: for (int index = 0; index < 100; index++) for (int subIndex = index; subIndex < 100; subIndex++) System.out.print("\r" + index + "/" + subIndex + " "); But when I try to run the same thing on windows, it prints out newlines instead of a carriage return. How can I achieve the same simple method of tracking the process on windows? 回答1: I had the statement and it worked in the command prompt

Is there an equivalent of BufferedReader.readLine() that lets me pick what my end of line characters are?

守給你的承諾、 提交于 2019-12-10 01:47:55
问题 The Javadoc for BufferedReader.readLine() says: A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. I need slightly better control than this (e.g. I would like to be able to specify that an end of line is "\r\n", so that an "\n" by itself does not terminate the line). Is there any JDK or library function which does this? 回答1: Try using the Scanner class: String line = Scanner(file)

How to prevent newline/line break within a <form></form>?

大兔子大兔子 提交于 2019-12-10 00:58:59
问题 This is my code. <form name="publish"> <?php include 'location.selector.html'; ?> <input type="submit" value="submit"/> </form> When displayed, there is a newline preceding the submit button, how to eliminate this newline/line break? The HTML content of location.selector.html is <table><tr><td>都道府県を選択してください</td> <td>市区町村を選択してください</td></tr> <tr><td align="center"> <SELECT name="pref" onChange="changePref(true)"> <OPTION VALUE="99">全国 <OPTION VALUE="0">北海道 <OPTION VALUE="1">青森県 <OPTION VALUE="2

In bash, How can I force a flush of an incomplete line printed to the terminal

夙愿已清 提交于 2019-12-09 19:29:55
问题 I'm writing a script which does something like the following: echo -n "Doing stuff, wait for it... " do_stuff (($?==0)) && echo SUCCESS || echo FAILURE Excuse the poor bash skills. Anyway, the problem is that the first part of the line doesn't get printed until do_stuff is done - while it is important to me the user know what I'm running next. It is also important to me, since I'm pedantic, not to print a newline. So, the text is in the buffer and doesn't get flushed. This question is very

Remove line breaks in Bourne Shell from variable

扶醉桌前 提交于 2019-12-09 05:11:03
问题 In bourne shell I have the following: VALUES=`some command that returns multiple line values` echo $VALUES Looks like: "ONE" "TWO" "THREE" "FOUR" I would like it to look like: "ONE" "TWO" "THREE" "FOUR" Can anyone help? 回答1: echo $VALUES | tr '\n' ' ' 回答2: Another method, if you want to not just print out your code but assign it to a variable, and not have a spurious space at the end: $ var=$(tail -1 /etc/passwd; tail -1 /etc/passwd) $ echo "$var" apache:x:48:48:Apache:/var/www:/sbin/nologin

How to add newlines or carriage returns to description on facebook graph API

久未见 提交于 2019-12-08 18:56:26
问题 It sounds like a pretty simple question but I can find the answer no where. I have a post from a textarea. and I want to use the current facebook php library to do the following... $description = $_POST['textarea_description']; //magic happens $attachment = array( 'access_token' => $token, 'message' => "$title", 'picture' => "$image_url", 'link' => "$action_link", 'name' => "$action_label", 'caption' => "$caption", 'actions' => $action_json, 'description' => "$description", ); $facebook->api(

Tell `endl` not to flush

馋奶兔 提交于 2019-12-08 18:35:29
My program prints a large number of short lines to cout . As a slightly contrived example, my lines look a little like this: cout<<"The variable's value is: "<<variable<<endl; I'd like the program to run fast and I do believe that endl is killing me because it initiates a buffer flush on cout every time it is used. Now, some folks on the internet have said that I could do this instead: cout<<"The variable's value is: "<<variable<<"\n"; But this does not seem like a good solution because endl abstracts the particular system-specific ways an end line might be specified, where as \n does not.