The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
23 views

removing the last line of a file not working? [duplicate]

I have this TXT file that is created by a bash script and at the end I want to remove the last line of that file that is an empty one. head --lines=-1 r3.txt > r4.txt sed '$d' r3.txt > r4.txt ...
0
votes
3answers
59 views

Is it possible to change the default COUNT value of tail and head?

The less command accepts its defaults with an environment variable LESS, so you can export LESS='-F -g -i -M -R -S -w -X -z-4' at the beginning of your session. Is it possible to change the ...
1
vote
2answers
70 views

will tail with piping read whole file?

I want to read a big log file with 10000 lines everytime. and I use this command: tail -c +offset somefile | head -n 10000 my question is, with the piping of head, will tail read the whole file? ...
4
votes
1answer
127 views

How can I colorize head, tail and less, same as I've done with cat?

I've got 'color cat' working nicely, thanks to others (see How can i colorize cat output including unknown filetypes in b&w?). In my .bashrc: cdc() { for fn in "$@"; do source-highlight ...
2
votes
1answer
312 views

Search and Filter Text on large log files

I use the tail, head and grep commands to search log files. Most of the time the combination of these 3 commands, in addition to using pipe, gets the job done. However, I have this one log that many ...
1
vote
1answer
125 views

POSIX head and tail not feature equivalent

The documentation for POSIX tail's -n option says that The origin for counting shall be 1; that is, -n +1 represents the first line of the file, -n -1 the last. So tail -n 10 (used later on the ...
9
votes
1answer
241 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 ...
1
vote
1answer
86 views

head command options and reading man files

I have two environments: Mac and Linux. I wonder about the head command: it can show just 2 lines of text if I invoke it like so: vim --version | head -2 I saw this online and ran to the man page ...
4
votes
0answers
72 views

Combing head and tail in a single call via pipe [duplicate]

On a regular basis, I am piping the output of some program to either head or tail. Now, suppose that I want to see the first AND last 10 lines of piped output, such that I could do something like ...
2
votes
1answer
114 views

Why can't I trim a file using `head`? [duplicate]

Given a file, foo.txt: 1 2 3 4 5 Say we want to change it to contain: 1 2 3 Why does head -n3 foo.txt > foo.txt leave foo.txt empty?
5
votes
2answers
1k views

Why does Subversion give a broken pipe error when piped into head?

If I do a svn log | head after the tenth line of output I get an error message: svn: Write error: Broken pipe What's going on here? I haven't seen any other command do this when used with head. ...
0
votes
1answer
91 views

Redirecting head output for update hosts file [duplicate]

Possible Duplicate: How can I make iconv replace the input file with the converted output? I'm writing a script to change the content of my hosts file but I got stuck on the head output ...
14
votes
8answers
6k 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. ...
15
votes
4answers
14k views

cat line X to line Y on a huge file

Say I have a huge text file (>2GB) and I just want to cat the lines X to Y (e.g. 57890000 to 57890010). From what I understand I can do this by piping head into tail or viceversa, i.e. head -A ...
6
votes
1answer
392 views

Peculiar piping grep/head behavior

I'm helping the netadmin here with a perl regex to automate operating on some snapshots from our SAN and our scripts does stuff like this: varinit1=$(iscsiadm -m session | grep rbmsdata1 | head -n1 | ...
5
votes
2answers
888 views

Why does `cat`ing a file into itself erase it? [duplicate]

Possible Duplicate: IO redirection and the head command I just wanted to remove all but the first line of a file. I did this: head -1 foo.txt ... and verified that I saw only the first ...
2
votes
2answers
1k 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 ...
22
votes
5answers
5k 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 ...