4
votes
4answers
153 views

How to get lines 10 to 100 from a 200 line file into a new file [duplicate]

I have file with 200 lines. I need to extract lines from 10 to 100 and put them into a new file. How do you do this in unix/Linux? What are the possible commands you could use?
1
vote
1answer
104 views

Convert newlines to null-delimited when using tail

How can I change the output from tail to use null-terminated lines instead of newlines? My question is similar to this one: How to do `head` and `tail` on null-delimited input in bash?, but differs ...
9
votes
1answer
288 views

How to do `head` and `tail` on null-delimited input in bash?

find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that ...
11
votes
4answers
853 views

How to do a continous 'wc -l' with gnu texttools?

I know of course that cat logfile.txt | wc -l 120 will tell me the number of lines in a file. Whereas tail -f logfile.txt will show me the new lines that another program writes to logfile.txt. ...
17
votes
8answers
11k views

Command to display first few and last few lines of a file

I have a file with many rows, and each row has a timestamp at the starting, like [Thread-3] (21/09/12 06:17:38:672) logged message from code..... So, I frequently check 2 things from this log file. ...
2
votes
2answers
2k views

How to execute this particular shell command from Python?

OK, so, I have this non-functional shell script, which I am rewriting piece by piece in python, except I am getting an "unexpected "|" error" from the shell (see below): #/bin/sh LINES=`cat $@ | wc ...
4
votes
1answer
2k views

How to follow (a la “tail -f”) a binary file from the beginning?

Is it possible to follow a binary file from the beginning, a la tail -f? This is useful in some cases, for example if I'm scping a file to a remote server, and at the same time I want to feed it to ...
22
votes
5answers
6k views

How to obtain inverse behavior for `tail` and `head`?

Is there a way to head/tail a document and get the reverse output; because you don't know how many lines there are in a document? I.e. I just want to get everything but the first 2 lines of foo.txt ...
12
votes
6answers
4k views

Best way to follow a log and execute a command when some text appears in the log

I have a server log that outputs a specific line of text into its log file when the server is up. I want to execute a command once the server is up, and hence do something like the following: tail -f ...