unix-head Questions

6

I have a big file around 60GB. I need to get n middle lines of the file. I am using a command with head and tail like tail -m file |head -n >output.txt where m,n are numbers The general structu...
Phonologist asked 9/12, 2013 at 7:7

9

Solved

Given a text file of unknown length, how can I read, for example all but the first 2 lines of the file? I know tail will give me the last N lines, but I don't know what N is ahead of time. So for ...
Anaesthetize asked 18/8, 2010 at 0:20

6

Solved

If I have a file name myownfile.txt which contains 3 lines of text. foo hello world bar I want to display the line in the middle which is hello world by using head and tail command only.
Aftergrowth asked 1/11, 2011 at 19:28

6

Solved

I've been able to track down basic head/tail functionality: head -10 myfile <==> cat myfile | select -first 10 tail -10 myfile <==> cat myfile | select -last 10 But if I want to list...
Stockstill asked 9/4, 2012 at 20:40

3

Solved

How can I select the lines from the second line to the line before the last line of a file by using head and tail in unix? For example if my file has 15 lines I want to select lines from 2 to 14. ...
Slicker asked 3/10, 2012 at 8:34

2

Solved

I would like to use a terminal/shell to truncate or otherwise limit a text file to a certain number of lines. I have a whole directory of text files, for each of which only the first ~50k lines a...
Kalpa asked 26/9, 2013 at 1:44

2

Solved

I have a java process which prints out a lot of text. Sometimes I just want to see a bit of the text. With normal programs I can just do: $ myprog | head I'll just see 10 lines of output from my...
Hoopen asked 27/7, 2012 at 20:52

4

Solved

I want to say output lines 5 - 10 of a file, as arguments passed in. How could I use head and tail to do this? where firstline = $2 and lastline = $3 and filename = $1. Running it should look li...
Duologue asked 1/4, 2013 at 17:6

2

Solved

Why doesn't yes | head hang? I thought the system collects all of the result from yes and then pipes it to head, and because yes is an infinite loop, the system hangs. But, it can actually stop an...
Fled asked 25/1, 2014 at 12:36

5

Solved

Is there a unix one liner to do this? head -n 3 test.txt > out_dir/test.head.txt grep hello test.txt > out_dir/test.tmp.txt cat out_dir/test.head.txt out_dir/test.tmp.txt > out_dir/test.h...
Hearne asked 12/11, 2013 at 18:3

4

Solved

I'm trying to search for a certain string in a lot of gziped csv files, the string is located at the first row and my thought was to get the first row of each file by combining find, zcat and head....
Souffle asked 27/7, 2010 at 2:21

4

Solved

Say I have a file with any number of lines, say, 125. I want to get all the lines except the first n, say, 20. So, I want lines 21–125. Is there a way to do this with with tail/head, or some other...
Rotman asked 24/11, 2008 at 14:46
1

© 2022 - 2024 — McMap. All rights reserved.