Skip to main content

View large file in Unix



You might had this experience many times while working in day to day Unix environments..


Viewing a Unix file very common in any Unix based task, however, there are large files in form of any log or any other data. Viewing such files really annoying to any administrator when this hits the following error.

 Out of memory saving lines for undo - try using ed
:
The reason why above error, default maximum lines can be displayed by "vi" editor is 1,048,560 so anything file more than 1,048,560 lines will not be displayed with "vi" editor.

May be below will show what you're looking for but will not allow much flexibility to view complete file

View the first 200 records

$head -n 200 yourfile.log |pg

to view the last 200 records

$tail -200 yourfile.log


How to solve this problem

"-y" switch of "vi" editor allows to overrides the maximum line setting of 1,048,560 with any value greater than 1024. You should request twice the number of lines that you require because the vi editor uses the extra lines for buffer manipulation.

Example

Below the command will set vi editors to display 99999999 lines at run time.

$vi -y 99999999 yourfile.log

More information you can find out with "man vi".

Hope this helps. Please let me know in case any queries.

Comments

Post a Comment

Popular posts from this blog

Alter System Checkpoint

Hello Techies, This happens most of the time that you need to add/drop redo log groups in Oracle databases due to any administrative reasons, however, if candidate redo group is in ACTIVE status, then you can't drop it and DBA need to wait until this comes in INACTIVE status to become this group available from drop. Here is the trick. Current status of redo log groups in my test database and you can see highlighted groups in ACTIVE status. In this situation, if DBA need to modify/drop these groups he/she need to wait until this comes in INACTIVE status. SQL> select * from v$log;     GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME      NEXT_CHANGE# NEXT_TIME ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------...

Oracle OS Watcher - Start and generate html report

Hi Guys, OS Watcher is an excellent utility for system performance investigation. OSWatcher invokes these distinct operating system utilities, each as a distinct background process, as data collectors. These utilities will be supported, or their equivalents, as available for each supported target platform. ps top ifconfig mpstat iostat netstat traceroute vmstat meminfo (Linux Only) slabinfo (Linux Only) OSWatcher is java program and requires as a minimum java version 1.4.2 or higher. This can run on on any Unix/Windows. An X Windows environment is required because oswbba uses Oracle Chart builder which requires it. Make sure java path is set $which java $<java path>/java Following will take system snapshot in every 30 seconds and will log last 24 hours data to OS Watcher archive log files. $cd <OS watcher dir> $nohup ./startOSWbb.sh 30 24 gzip <OS Watcher file location> & Without compress $nohup ./s...

Oracle Trace File Analyzer (TFA)

Hi Guys, Oracle Trace File Analyzer (TFA) is a powerful diagnostic tool which provides a number of diagnostic tools in a single bundle and making it easy to gather diagnostic information about the Oracle database and Clusterware, which in turn helps with problem resolution when dealing with Oracle Support. Download TFA Install TFA Run a TFA collection. Upload TFA collection to My Oracle Support (MOS) Download TFA. Download the latest version from here .  Install TFA This is recommended that TFA should be installed from " root " OS user which provides the most functionalities and allows it to run in a proactive manner as a daemon, or locally as the Oracle software owner. Here I did this from root to do proactive tool. Unzip the software, create a destination location and install the software using the "-local" flag (if not doing this for RAC). unzip command path is mandatory for installing the TFACTL Locating th...