Sponsored Content
Homework and Emergencies Homework & Coursework Questions UNIX head command not working? Post 302928849 by lukefrost96 on Monday 15th of December 2014 02:09:01 PM
Old 12-15-2014
I honestly thought that the code I had written was right, just needed tweaking to get rid of the error.

I'm assuming you pass the files in the directory to tail or head by using the -n option to specify the amount of lines.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

head command

Hi All, How can the head command be used to extract only a particular line. By default head -n filename displays the first n lines. I want only the nth line. I couldn't get it from forum search. Thanks, Sumesh (6 Replies)
Discussion started by: sumesh.abraham
6 Replies

2. UNIX for Dummies Questions & Answers

alternative for head command

Hi friends,I am new to unix and this is really a dummy question.but please help me out. How to simulate head command without using head command??? also tail command too,also more command. it is given as a homework to do....please tell me how to do (2 Replies)
Discussion started by: nikhilneela
2 Replies

3. Shell Programming and Scripting

head command with more than one file

Hi, I have the following problem. I have files with one column of data (let's say file1.dat, file2.dat...file6.dat), and I would like to record the first value of the column of each file into another file (let's name it fileall.dat), which would have the the six values, one in each column. I use to... (4 Replies)
Discussion started by: josegr
4 Replies

4. Shell Programming and Scripting

cp command not working in script for non unix file

Piece of code in sh file ------------------------ echo "lalit test bef" which cp cp $l_options $srcdirfile $destdirfile echo "lalit test after" echo "**************************options below" echo "loption $l_options" echo "src $srcdirfile" echo "destinat... (3 Replies)
Discussion started by: lalitpct
3 Replies

5. Homework & Coursework Questions

Unix find and head command help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I've been stuck on this problem for 2 days now What command would you enter to list the first lines of all text... (11 Replies)
Discussion started by: partieboi37
11 Replies

6. Shell Programming and Scripting

Diff/head - not sure if this is the right command to use

Hi, I need some advise on whether there is a better way of doing what I am currently planning to do. Perhaps I should be using arrays instead of re-directing output to files? I need to use a tool/program named ADRCI provided by Oracle to remove trace files that it generates. Honestly it is... (1 Reply)
Discussion started by: newbie_01
1 Replies

7. Shell Programming and Scripting

UNIX command in cron not working

the following unix command gives me the number of records avaiable in my application /navs/sys/appl/bin/record list This gives number of rows and colums. I want to generate one text file everyday at 6:10 AM using cron So I added following entery into crontable #Generate record file at... (6 Replies)
Discussion started by: Nakul_sh
6 Replies

8. Shell Programming and Scripting

sed Command not working in AIX UNIX

Hi 1st problem -------------- i have this sed command in my unix script which replaces new line and carriage return in a line with the string "&#xA" the script works fine in Linux 3.0.101-0.5, but not in AIX 1 7 , the "s/\r/\&#xA/g" replacement, replaces all the character "r" in the file.... (3 Replies)
Discussion started by: maximus_jack
3 Replies

9. Shell Programming and Scripting

Head command queries

we have a file as below AREA,COUNTRY,RANK A,MX,1 A,MX,2 A,MX,5 A,MX,8 A,IN,7 A,IN,5 A,IN,21 B,CN,6 B,CN,2 B,CN,8 B,CN,0 we need the TOP 2 RANK records for the combination of Area, Country as below. i know head -2, which gives top 2 records from file but not sure it lists based on... (7 Replies)
Discussion started by: JSKOBS
7 Replies
HEAD(1P)						     POSIX Programmer's Manual							  HEAD(1P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
head - copy the first part of files SYNOPSIS
head [-n number][file...] DESCRIPTION
The head utility shall copy its input files to the standard output, ending the output for each file at a designated point. Copying shall end at the point in each input file indicated by the -n number option. The option-argument number shall be counted in units of lines. OPTIONS
The head utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines. The following option shall be supported: -n number The first number lines of each input file shall be copied to standard output. The application shall ensure that the number option- argument is a positive decimal integer. When a file contains less than number lines, it shall be copied to standard output in its entirety. This shall not be an error. If no options are specified, head shall act as if -n 10 had been specified. OPERANDS
The following operand shall be supported: file A pathname of an input file. If no file operands are specified, the standard input shall be used. STDIN
The standard input shall be used only if no file operands are specified. See the INPUT FILES section. INPUT FILES
Input files shall be text files, but the line length is not restricted to {LINE_MAX} bytes. ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of head: LANG Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files). LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES . ASYNCHRONOUS EVENTS
Default. STDOUT
The standard output shall contain designated portions of the input files. If multiple file operands are specified, head shall precede the output for each with the header: " ==> %s <== ", <pathname> except that the first header written shall not include the initial <newline>. STDERR
The standard error shall be used only for diagnostic messages. OUTPUT FILES
None. EXTENDED DESCRIPTION
None. EXIT STATUS
The following exit values shall be returned: 0 Successful completion. >0 An error occurred. CONSEQUENCES OF ERRORS
Default. The following sections are informative. APPLICATION USAGE
The obsolescent - number form is withdrawn in this version. Applications should use the -n number option. EXAMPLES
To write the first ten lines of all files (except those with a leading period) in the directory: head * RATIONALE
Although it is possible to simulate head with sed 10q for a single file, the standard developers decided that the popularity of head on historical BSD systems warranted its inclusion alongside tail. This standard version of head follows the Utility Syntax Guidelines. The -n option was added to this new interface so that head and tail would be more logically related. There is no -c option (as there is in tail) because it is not historical practice and because other utilities in this volume of IEEE Std 1003.1-2001 provide similar functionality. FUTURE DIRECTIONS
None. SEE ALSO
sed, tail COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 HEAD(1P)
All times are GMT -4. The time now is 12:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy