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 :eek:) 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.

try:

awk 'FNR==1 {print $0; exit} ' input*.txt > output.txt

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).:frowning:

Install Fink then install their coreutils 1:6.9-3 package. The head command in this package supports the --quiet option.

or

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.