Showing posts with label solaris. Show all posts
Showing posts with label solaris. Show all posts

Tuesday, January 15, 2013

How to extract a range of lines from a large file?

It is not advisable to use vi to view a large file as on most system vi will create a swap file of similar size. It is better to extract the lines of interest to another file. Say you want to extract lines 20001 to 30000 from a log file. There are many ways to accomplish that and I am going to show you 2 of them here.

sed (my preferred way)
sed -n -e '20001,30000p' log.txt > /tmp/log-small.txt
-n means don't print anything unless the p command is used. -e means execute the following expression (those inside '....'). 20001,30000p means for lines 20001 to 30000 inclusive, execute the command p, which prints them to the console.

the head & tail way
head -30000 log.txt | tail -10000 > /tmp/log-small.txt

The head command will output lines 1 to 30000 and pipe to tail which will print the last 10000 lines, i.e. lines 20001 to 30000.
As you can see, the head & tail way requires some mental arithmetics and so it is not my preferred way.

Wednesday, January 09, 2013

How to find out Solaris version number?

Depending on what information you want, the following commands will provide different information about a Solaris server:
  • cat /etc/release
  • showrev
  • uname -a

Thursday, August 30, 2012

How to check available memory in Solaris?

There are many ways to check available memory in Solaris. One of the commands is:
prtconf | grep Memory