1830898 Members
2731 Online
110017 Solutions
New Discussion

more header

 
SOLVED
Go to solution
Gilbert Standen_1
Frequent Advisor

more header

Porting a script to another server, and ran into this: my script uses "more" and often pipes the results to sed, tail, wc, etc. On this particular box, the "more" command when piped in this way is pre-pending a "header" to the output of the file which looks like this:
:::::::::::::::::::::::::::
/full/path/to/file/filename
:::::::::::::::::::::::::::
This is causing some of the piped commands to go haywire as they are not looking for that header. I'm recoding to handle this as it's a bug in the general portability of the script, but can anyone tell me where one configures more to pre-pend such a header and if this feature can be turned off ? I have not seen this previously on other HPUX or AIX boxes. BTW if you run more from the command line, and pipe it to sed, etc. it does not do this. It seems to happen only when run from the script.
If I could take one thing with me into the next world it would be my valid login to HP ITRC Forums
4 REPLIES 4
Patrick Wallek
Honored Contributor
Solution

Re: more header

There is no configuration for the 'more' command. It would almost have to be something custom. It sounds to me like it is some sort of alias that someone set up.

The first thing I would do is examine the 'more' file and see what it looks like. In HP-UX you should be using /usr/bin/more and if you do a 'file /usr/bin/more' you should see it as 'PA-RISC 1.1 shared executable' and if you do a 'what /usr/bin/more'' you should see some HP revision information.

Now, in your script are you just doing a 'more' or are you doing a '/usr/bin/more'? It is ALWAYS a good practice to use fully qualified paths to executables so you don't run into surprises.

If you must make sure this is portable then you could add something like this to your script:

OS=$(uname)

case ${OS} in
HP-UX) MORE=/usr/bin/more ;;
AIX) MORE=/path/to/more ;;
esac

${MORE} somefile

A. Clay Stephenson
Acclaimed Contributor

Re: more header

More isn't an SVID command so I tend to avoid it preferring instead the pg command. Of course, the standard command 'pg' is typically not implemented on Linux proving once again that Linux ain't UNIX. In any event, the behavior of more does change depending upon whether or not the output device is a tty device -- and this behavior is documented. The very first thing I would check is to see if the environment variable MORE is set; if so, then you are getting some more options set automatically that you don't know about.
If it ain't broke, I can fix that.
Gilbert Standen_1
Frequent Advisor

Re: more header

As Mr. Stephenson suggested, re-red the man page on "more" with regard to output of more and found this in the documentation:

"If the standard output is not a terminal, more acts just like cat, except that a header is printed before each file in a series."

My problem is solved by just switching over to cat, which causes the header issue to go away. Your help with this is very much appreciated. I should have been using cat all along anyway, as my need is to write out entire files to other piped processes such as sed, and not to page through files.

Also odd to note that I have run this same script on other UNIX servers using "more" (both HPUX and AIX) and did not get the headers and yet this one gives them.
If I could take one thing with me into the next world it would be my valid login to HP ITRC Forums
A. Clay Stephenson
Acclaimed Contributor

Re: more header

Well fuss at them XPG4 folks if the more command doesn't work "correctly"; my approach is to avoid commands in scripts that aren't SVID compliant but that's just me.

--- And while we are on the subject of more, here is a true epitaph on both less and more:

Here lies Lester Moore.
Four slugs
From a forty-four.
No Les
No More.

Boot Hill Cemetery, Tombstone, Arizona

-------------------------------
Les would have probably been better off if he used pg as well.
If it ain't broke, I can fix that.