Help with head -q option on Mac OS X


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) Help with head -q option on Mac OS X
# 1  
Old 07-30-2009
Question Help with head -q option on Mac OS X

I am trying to run a csh script (this is usually done on my Linux machine but it died, so I had to resort to a Mac Smilie) and I received the following error message:

head: illegal option --q

My script takes multiple files as the input, concatenates them and produces a single file as the output. The line that is giving me issues is listed below:

head -1 -q input*.txt > output.txt

If I remove the -q option, it does still work; however, it is adding the name of each, individual file to output.txt.

From what I have read, OS X does not support the quiet or silent (-q)option. Does anyone know of another option that would give me the same result? Any suggestions would be greatly appreciated.
# 2  
Old 07-30-2009
try:
Code:
awk 'FNR==1 {print $0; exit} ' input*.txt > output.txt

# 3  
Old 07-30-2009
Thanks for the reply, Jim. Sadly, the code caused only the first line of the first file to be written to the output file but ignored all the remaining files (there are 50 files in total).Smilie
# 4  
Old 08-01-2009
Install Fink then install their coreutils 1:6.9-3 package. The head command in this package supports the --quiet option.
# 5  
Old 08-28-2009
or

Code:
head -1 input*.txt | grep -v '==>' > output.txt

The Mac OS X head command outputs "==>" along with filename, so just delete that line and you should be good to go.
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

2. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

3. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies
Login or Register to Ask a Question