Reputation: 2142
I want to execute yum list installed > file.txt
and output results to a txt file which is NOT wrapped by X characters. At least, I want to be able to control "width" of this output buffer.
I know that stty columns 250
will set column width of my console window to 250 characters but how do I accomplish this when I redirect output to a file?
This has certainly been asked before but I just could not find an answer...
Edit:
This seems to be a yum
thing since ps aux > ps.txt
works just fine. With yum, file is limited to only 80 characters so I'm adding yum tag. I have no idea how can yum give different output on screen and on the file while other programs work just fine (also note that I'm a beginner in bash).
Upvotes: 5
Views: 3175
Reputation: 30597
I stumbled across a hackish way to do this using screen
:
screen -L yum --color=never list installed
This will result in a file called screenlog.0
containing the output, and yum will think it is outputting to a TTY with the same width as your current screen.
Upvotes: 4
Reputation: 16039
I think you have two options.
Edit the yum source (http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz). The 80 is hard coded in output.py, line 53.
It's probably doable to make yum believe it is writing to a terminal. Whether -- and if, how -- it is possible to set the number of columns for that fake terminal I am not sure of. One thing that pops up is Linux' unbuffer
(cf. Piping data to Linux program which expects a TTY (terminal)). Perhaps a little self written unbuffer-like C wrapper may use a pty and have more control over it; even bash may have an esoteric feature for that.
Upvotes: 4