Operating System - HP-UX
1833798 Members
2969 Online
110063 Solutions
New Discussion

I redirected command output to a file

 
SOLVED
Go to solution
cbozlagan
Regular Advisor

I redirected command output to a file

Hi,
In my HPUX 11.11 system
I redirected command output to a file

But long lines in file splited into two or more lines.

I want the lines whatever length they have must not to be splitted.

I transferred the file to PC and open with MS Word. And I did font very small and page landscape, but lines remain same.

How can I solve this problem?

Thanks.

10 REPLIES 10
Torsten.
Acclaimed Contributor

Re: I redirected command output to a file

Hi,

I'm quite sure "Word" is splitting the lines.

"cat" the file on your HP-UX host and you will see the "long lines".
Use another tool on your PC to open the file, e.g. notepad, notepad++ or whatever.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Wouter Jagers
Honored Contributor

Re: I redirected command output to a file

Didn't they get split up on the windows pc ?

Can you vi or cat the output file on the unix box and check ? It would be weird (to say the least) for this to happen on your unix machine.

Cheers,
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
Yogeeraj_1
Honored Contributor

Re: I redirected command output to a file

hi,

a few thing you can try:

1. transfer the file using FTP (ASCII mode)
2. Open the file using NOTEPAD

check and let us know

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Peter Nikitka
Honored Contributor

Re: I redirected command output to a file

Hi,

the output of the command
nl myfile

numbers non-empty lines - so you can determinate, if a split occures only on the output of the file.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Andrew Merritt_2
Honored Contributor

Re: I redirected command output to a file

How are you determining if the lines are actually split while still on HP-UX? Most ways of displaying the lines will wrap the text, but the file content will not be affected.

Andrew
cbozlagan
Regular Advisor

Re: I redirected command output to a file

I'm trying to determine, if the lines were originally splited.

Thanks for your help

Bill Hassell
Honored Contributor
Solution

Re: I redirected command output to a file

You are using programs to look at your file that are too small to see the file correctly. Most modern terminal emulators can be changed to display at least 132 characters, good emulators have no limits at all. I use a screen size of 176 wide by 66 lines. That still isn't wide enough but the font is very small so I have to look at the lines correctly. The first item is your terminal's handling of the last column on the screen. Does your emulator simply wrap around to the next line, or does it split the line on a word boundary, or does it simply stay at the last column overwriting the last character over and over?

When you redirect output from a program, the file will have no splits. You can verify this with wc. If real splits take place, the file will have more lines than the original. When you run vi on the file, vi can split lines depending on the setting of wm. You change the wm option (wrap margin) to zero in .exrc or change it with :set wm=0 before you open the file. Then type the command $ which moves to the end of the line. A very long line will see the cursor move down the page to the end of the line. Type 0 (zero) to go back to the beginning. vi can handle and properly display lines more than a thousand characters long.

PCs are very inept at handling text files. Notepad will wrap lines in the window but if you widen the window, you will see the line getting longer. It really is not split. Look at the Notepad options to control word wrap. MS Word is a word processor so by default, Word will split the lines. If you want Word to display (and print) the complete lines then change the page layout to landscape and change the font to 6. That should give you about 250 characters across the page. Oh, you probably will have difficulty reading such a small font. The size of the font you need depends on the maximum length of the line.

Your file was probably not split, only your display window or word processor made it look that way.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: I redirected command output to a file

>Peter: nl myfile

You can also use the following in vi to see line numbers:
:set nu

>numbers non-empty lines

You can use "nl -ba" to number every line.

>Bill: When you redirect output from a program, the file will have no splits.

bdf(1) is a rotten exception and splits lines if the filesystem is "long".
Bill Hassell
Honored Contributor

Re: I redirected command output to a file

Dennis writes:

> bdf(1) is a rotten exception and splits lines if the filesystem is "long".

In this case, the program has decided to split the lines, one of those legacy things from the days of vt100's, Beehives and Lear Siegler ADM3A's with just 80 characters on the screen. Even the 'better' bdf (gdf) splits lines. bdfmegs solves the problem.


Bill Hassell, sysadmin
Peter Nikitka
Honored Contributor

Re: I redirected command output to a file

Hi,

when the main theme is 'splitting of lines', it fits best to get a numbered output ignoring empty lines, IMHO (>Dennis).

Having a possibly large output file, it may be not a good idea to feed vi with it.

To get a statistics of the length of lines, you can use
awk 'BEGIN {print "line\tlength"}
{n=length($0);printf("%d\t%d\n",NR,n);if (n>max) {max=n;li=NR}}
END {printf("longest line(%d) has %d chars\n",li,max)}' outfile

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"