Questions tagged [unix-head]

The Unix `head` command displays the leading lines of a file.

head is a unix command which displays the first lines of a file. It's counterpart which displays the last lines is tail ().

Example: head -n 10 file will output first 10 lines of file.

55 questions
1
vote
1 answer

unix tty hang after tail with acute (`)

Hi i run a command on Linux server. tail -3 `ls -1t nnnn* | head -1` When nnnn file exist, all good. When nnnn file not exist the tty is hanged until ^C nt-home-stg>> tail -3 `ls -1t nnnn* | head -1` ls: No match. After the ls: No match. it…
ReDevil
  • 77
  • 6
1
vote
1 answer

How can I simulate the unix head command in Node.js synchronously?

Looking for a synchronous method in Node.js that is like linux head. I know it's generally a bad idea to do synchronous stuff in node, but I have a valid use case. Need to read the first few lines of a file.
john.stein
  • 535
  • 4
  • 8
1
vote
2 answers

Expressing tail through a variable

So I have a chunk of formatted text, I basically need to use awk to get certain columns out of it. The first thing I did was get rid of the first 10 lines (the header information, irrelevant to the info I need). Next I got the tail by taking the…
1
vote
0 answers

Head command not working in Unix Script

I need help in unix scripting. I am trying to use the head command in unix script but it's showing some errors. for file_name in $(cat files.lst); do echo $file_name file_count=$(head -n1 ${file_name} | awk -F '|' '{print NF}') echo…
Naveen
  • 11
  • 2
1
vote
3 answers

remove n lines from STDOUT on bash

Do you have any bash solution to remove N lines from stdout? like a 'head' command, print all lines, only except last N Simple solition on bash: find ./test_dir/ | sed '$d' | sed '$d' | sed '$d' | ... but i need to copy sed command N times Any…
Dmitry Dubovitsky
  • 2,186
  • 1
  • 16
  • 24
0
votes
1 answer

Bash function argument unexpectedly interpreted as file/directory

I created a function in my .bashrc file to print the top N files/directories in the working directory: # .bashrc function topN () { du -hs * | sort -rh | head -"$1"; } However, sourcing my .bashrc and then running topN 5 returns: head: cannot open…
IslandPatrol
  • 261
  • 3
  • 11
0
votes
0 answers

Implement the functionality of the wc and head controls

I need help to solve these requirements: Implement the functionality of the wc and head controls. The wc command will need to use and recognize the -w and -c options. The head command will need to use and recognize the -c and -n options. The…
0
votes
0 answers

Implement unix utility "head" in C++

I'm trying to implement the unix utility "head" in C++. I'm overriding std::stringbuf::sync and returning eof(). But on the ostream, eof does not get set. Even better, it would be nice if it threw an exception. online code #include…
Aaron Frantisak
  • 543
  • 5
  • 11
0
votes
2 answers

Trim top and bottom rows from CSV UNIX SH

I need to trim the top 5 rows and the last row of my csv using a Unix command that I can run in a shell script. I currently have head -n -1 file.csv | tail -n +6 file.csv > newfile.csv this outputs a new csv starting from row 6 which is what I…
slackerr
  • 11
  • 1
  • 3
0
votes
0 answers

how to use tee command to redirect the output to two different commands in tcsh shell

I am trying to sort the output of an awk script which contains 2 lines of header information (which should not be sorted). For that I am using tee command in tcsh shell as shown below awk -f scr.awk tmp.txt | tee >(head -n 2 > tm) >(tail -n +3 |…
yow
  • 13
  • 1
  • 4
0
votes
2 answers

Chunk text files with BASH

I am relatively new to Bash and I would like to chunk a txt contained in a zip file. The chunk must be from 5 lines up from "channel8" to 2 lines up from "channel10" 12082008;pull done;ret=34;Y 08072008;push hanged;s=3;N 15082008;pull…
JPV
  • 1,079
  • 1
  • 18
  • 44
0
votes
1 answer

How to open a latest file in a sub directory in Linux?

I have a logs/ directory which contains many log files. I would like to open the latest log file. My env is Ubuntu 16. I know the name of the latest file. But the file is in logs/ dir. In such a case, how do I tell the relative pass via xargs? $ ls…
jef
  • 3,890
  • 10
  • 42
  • 76
0
votes
1 answer

Command HEAD in Cygwin doesn't work

I'm a Windows sysadmin trying to setup a Cygwin in a Windows 2016 environment. Not a Linux or developer person, but I'm open to learn. I'm able to install Cygwin (x86/64) and most of the commands work just fine. But there is 2 commands that doesn't…
0
votes
1 answer

bash: how to display the first 10 lines using qstat?

In bash, typing qstat will show all the job status. 4426868 0.00000 md_0_1 username hqw 12/31/2017 11:45:25 12 4426869 0.00000 md_0_1 username hqw 12/31/2017 11:45:25 …
lanselibai
  • 1,203
  • 2
  • 19
  • 35
0
votes
5 answers

Bash: get value of one column based on value of another column

I have a space-separated file that contains: 5.75e-01 7.00e-1 5.52e-01 7.33e-01 ./dir1/dir2/file1.csv 5.75e-01 7.00e-1 5.42e-01 7.34e-01 ./dir1/dir2/file2.csv 5.75e-01 7.00e-1 5.72e-01 7.43e-01 ./dir2/dir2/file1.csv 5.75e-01 7.00e-1 5.22e-01…
StatsSorceress
  • 3,019
  • 7
  • 41
  • 82