line

How do I get the last non-empty line of a file using tail in Bash?

How do I get the last non-empty line using tail under Bash shell? For example, my_file.txt looks like this: hello hola bonjour (empty line) (empty line) Obviously, if I do tail -n 1 my_file.txt I will get an empty line. In my case I want to get bonjour. How do I do that? ...

How do I delete the first line in a file?

I can't search for a particular string, since they're all very similar, but I'd like something simple to chop out the first 4 lines in a file. They're all variable length too. I've had a a think about perl, and it all seems harder than I thought, but I'd like to do it in Perl, AWK or a shell command if possible. Does anybody have a si...

Matab - Trace contour line between two different points

Hi, I have a set of points represented as a 2 row by n column matrix. These points make up a connected boundary or edge. I require a function that traces this contour from a start point P1 and stop at an end point P2. It also needs to be able trace the contour in a clockwise or anti-clockwise direction. I was wondering if this can be ac...

Android vertical line xml

Hello, I'm trying to figure out how to define a verical line (1px thick) to be used as a drawable. to make a horizontal one, it's pretty straightforward: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="#0000FF"/> <size android:height="50dp" /> ...

How to display two series via Google Chart API?

I can't get the two series of numbers to scale together. Here is sample code that you can paste into... http://code.google.com/intl/en/apis/chart/docs/chart_playground.html cht=lxy chs=400x300 chd=t:20,30,40|1,4,2|24,34,44|3,7,1 chds=20,40,1,4,24,44,1,7 chxr=0,20,54,2|1,0,7,1 chxt=x,y chxs=0,ff0000,12,0,lt 1,0000ff,10,1,lt chco=FF...

Recognising the type of graph by given set of points.

I'm trying to design a program that draws graphs given a set of points (x, y), and it also should recognize the curve (straight line, hyperbole, parabola), with only the help of the points. Is there an algorithm to do that? ...

Draw a smooth line with finger touch on iPhone

Hello Everyone, How do I draw a smooth line with a finger slide/touch motion on the iPhone? I have the following code but it is not smooth. It makes corners/turns for example when I try to do a circle. I think I have to use OpenGL. Any ideas? sample code? tutorials? Thanks! UIGraphicsBeginImageContext(self.view.frame.size); [draw...

Finding Line Beginning using Regular expression in Notepad++

Finding Line Beginning using Regular expression in Notepad++ (Sorry if this is a newbie question) I want to strip a 4000-line HTML file from all the jQuery "done" stuff, e.g.: <DIV class=menu done27="1" done26="0" done9="1" done8="0" done7="1" done6="0" done4="20"> should be replaced with: <DIV class=menu> In http://www.zytrax.co...

get entire line with java.util.scanner.hasNext(regex)

I'm doing something in Java that requires input to be matched against the pattern ^[1-5]$. I should have a while loop looping through each line of input, checking it against the pattern, and outputting an error message if it does not. Sudo code: while (regex_match(/^[^1-5]$/,inputLine)) { print ("Please enter a number betwee...

Oracle SQL CMD Line

Whenever I perform select statements in the command line tool it doesn't use all of the space. I've modified buffer size and window size and it just doesn't work. Here is the screenshot: ...

C# printing by line to a passbook

hi all! my question has something to do with printing. i was wondering how you could pass values to a printer. we are using a CRADEN DP4 printer which is used for passbooks for banks. i was wondering how could we print into a passbook using c# and the craden DP4 printer. i visited the manufacturer site and it does not have driver support...

jQueryUI Tabs: how to keep them on a single line?

Hi all, Maybe my question is wired: is there a way to prevent jQueryUI tabs from floating if browser window is too small? Explanation: I have a simple horizontal tab using CSS only. The content is floating but not the tabs. Important: there is no width set manually, the current width is taken automatically. Here is the code: <!DOCTYPE...

CursorLine highlight in ViM, highlight only line number and spaces/tabs on beginning /end of the line

Hi, I use ViM's :highlight CursorLine to change bg color on the current line. But sometimes is the text not readable. I would like a highlight that could only change bg color for the whole line except the text (counting the spaces/tabs in between chars as text). Is it doable? If yes, how? Thanks ;) ...

replace line with sed in csh

Hello, I am trying to change the content of a specific line in a batch of files. I thought that would be a piece of cake but for some reason, nothing happens, so I guess I am missing something. Line 8 should have been replaced. Here the csh script I used: #!/bin/csh # # replace context in line xxx by yyy # 2010/05/07 set files = `ls ...

sed: search and replace string with line number

Hi volks, I have a XML file with a lot of empty tag attributes. For instance: <mytag id=""> <ontent>aaa</content> </mytag> <mytag id=""> <ontent>bbb</content> </mytag> <mytag id=""> <ontent>ccc</content> </mytag> Now I want to replace id="" with e.g. id="2443" (id="[linenumber]") I tried to do this with sed, but I did not get ...

Add centered text to the middle of a <hr/>-like line

I'm wondering what options one has in xhtml 1.0 strict to create a line on both sides of text like-so: Section one ----------------------- Next section ----------------------- Section two I've thought of doing some fancy things like this: <div style="float:left; width: 44%;"><hr/></div> <div style="float:right; width: 44%;"><hr/></d...

in tcl, how do I replace a line in a file?

let's say I opened a file, then parsed it into lines. Then I use a loop: foreach line $lines {} inside the loop, for some lines, I want to replace them inside the file with different lines. Is it possible? Or do I have to write to another temporary file, then replace the files when I'm done? e.g., if the file contained AA BB and ...

Delphi: Center Specific Line in TRichEdit by Scrolling

I have a Delphi 2007 TRichEdit with several lines in it. I want to scroll the richedit vertically such that a specific line number if approximately centered in the visible/display area of the richedit. For example, I want to write the code for CenterLineInRichEdit in this example: procedure CenterLineInRichEdit(Edit: TRichEdit; LineNu...

Why doesn't JFreeCharts correctly connect the points in my xy-line graph?

Each letter A,T,G,C represents a direction for the plot to graph. Specifically, “A” means move right, “T” is move down, “C” is move up, and “G” is move left. When the applet reads A,T,C, it plots the graph correctly. However, when I plot G, the graph is messed up. When I input "ACACACA," the graph is like a rising staircase. When I input...

split line of text

Hi all, I was wondering if there is an algorithm to split a line into multiple lines, so that the resulting set of multiple lines fit into a squared shape rather than a wide rectangular shape. Let me give some examples, Input: Hi this is a really long line. Output: Hi this is a really long line Input: a b c d e f Output: a b c d e...