Opening Large Log Files in Unix
How to open or view large log files in unix. vi editor complains of the file being too large to open. ---->
---->
#!/bin/sh
if [ $# -ne 2 -a $# -ne 3 ] ; then
fname=$1
if [ ! -r $fname ] ; then
workfile=/tmp/viewpart$$ if [ "$lines" ] ; then
vi $workfile echo "\nRemove workfile $workfile ? [yn] \c"
if [ "$answer" = y ] ; then
exit 0 ---->
While in the vi editor, type the command: :set dir This will display the directory where vi is opening files. If it is pointing to a small filesystem, type the command: :set dir=/tmp (or other large filesystem) You can now open the file by typing: :r <filename> Don't use the angle brackets around filename, it's just to highlight the syntax. The options previously proposed are good ones and the script looks nice. This is just a "FYI" regarding temp files in vi. If you need to set these everytime you open vi then create a .exrc file. The file will read: set dir=/tmp Set the ownership of the file so others cannot change it. Commands can be placed in the .exrc file and will execute when vi is invoked. This is not a good thing if you are root. It can be used to do interesting things.
See Also
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|