Questions tagged [line]

The shortest distance between two points. Or, a row of characters in text output.

is mostly used in below context:

  • text line or command line in text processing context;
  • line drawing or plotting in visualization or image-processing context
  • analytic geometry
5617 questions
398
votes
6 answers

Get line number while using grep

I am using grep recursive to search files for a string, and all the matched files and the lines containing that string are print on the terminal. But is it possible to get the line numbers of those lines too?? ex: presently what I get is…
sai
  • 4,377
  • 4
  • 21
  • 18
397
votes
13 answers

Reading a file line by line in Go

I'm unable to find file.ReadLine function in Go. I can figure out how to quickly write one, but I am just wondering if I'm overlooking something here. How does one read a file line by line?
g06lin
  • 4,285
  • 2
  • 15
  • 12
270
votes
19 answers

How do you make div elements display inline?

Given this HTML:
foo
bar
baz
How do you make them display inline like this: foo bar baz not like this: foo bar baz
Steve
  • 5,483
  • 7
  • 29
  • 33
252
votes
4 answers

Go to first line in a file in vim?

How do I go to first line in a file in vim ?
Jean
  • 18,513
  • 22
  • 63
  • 104
242
votes
34 answers

Add centered text to the middle of a
-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:
Brian M. Hunt
  • 71,376
  • 65
  • 208
  • 328
242
votes
28 answers

How to read specific lines from a file (by line number)?

I'm using a for loop to read a file, but I only want to read specific lines, say line #26 and #30. Is there any built-in feature to achieve this?
eozzy
  • 58,300
  • 96
  • 249
  • 396
213
votes
17 answers

C read file line by line

I wrote this function to read a line from a file: const char *readLine(FILE *file) { if (file == NULL) { printf("Error: file pointer is null."); exit(1); } int maximumLineLength = 128; char *lineBuffer = (char…
lron
  • 2,147
  • 2
  • 13
  • 3
208
votes
28 answers

Circle line-segment collision detection algorithm?

I have a line from A to B and a circle positioned at C with the radius R. What is a good algorithm to use to check whether the line intersects the circle? And at what coordinate along the circles edge it occurred?
Mizipzor
  • 45,705
  • 20
  • 92
  • 136
191
votes
10 answers

How do you run a command for each line of a file?

For example, right now I'm using the following to change a couple of files whose Unix paths I wrote to a file: cat file.txt | while read in; do chmod 755 "$in"; done Is there a more elegant, safer way?
hawk
  • 2,035
  • 2
  • 14
  • 9
189
votes
5 answers

How do cache lines work?

I understand that the processor brings data into the cache via cache lines, which - for instance, on my Atom processor - brings in about 64 bytes at a time, whatever the size of the actual data being read. My question is: Imagine that you need to…
Norswap
  • 10,130
  • 10
  • 42
  • 57
173
votes
17 answers

Vertical line using XML drawable

I'm trying to figure out how to define a vertical line (1dp thick) to be used as a drawable. To make a horizontal one, it's pretty straightforward:
Kaspa
  • 2,049
  • 2
  • 16
  • 17
171
votes
11 answers

How to split strings over multiple lines in Bash?

How can i split my long string constant over multiple lines? I realize that you can do this: echo "continuation \ lines" >continuation lines However, if you have indented code, it doesn't work out so well: echo "continuation \ …
user880248
169
votes
26 answers

How to add a line break in an Android TextView?

I am trying to add a line break in the TextView. I tried suggested \n but that does nothing. Here is how I set my texts. TextView txtSubTitle =…
dropsOfJupiter
  • 6,445
  • 11
  • 44
  • 59
161
votes
6 answers

How to paste text to end of every line? Sublime 2

I'm curious if there is a way to paste text to the end of every line in Sublime 2? And conversely, to the beginning of every line. test line one test line two test line three test line four ... Say you have 100 lines of text in the editor, and you…
Tony H.
  • 1,915
  • 4
  • 14
  • 20
158
votes
12 answers

Remove empty lines in text using Visual Studio

How to remove empty lines in Visual Studio?
Alaa
  • 7,984
  • 16
  • 52
  • 83
1
2 3
99 100