Posts

Tested & verified 50 useful AWK One Liners

1. How to print the line which matches /regex/?    awk '/regex/{print $0}' 2. How to print the line immediately above the line containing /regex/? awk '{x=y"\n"$0;y=$0};x~/regex/{gsub(/\n.*/,"",x);print x}' 3. How to print the line immediately after the line containing /regex/? awk ' {x=NR+1};NR==x{print $0}' 4. How to get the uniq lines from a file & the count the line is repeated? awk '{arr[$0]++;};END { for (i in arr) { print i "\t" arr[i];} }' 5. Precede each lines with its line number. awk ‘{print NR “\t” $0}’ 6. Precede line numbers only on the non-blank lines. awk 'NF{++c; print  c "t" $0};NF==0{print $0}' 7. Count the Lines. awk ‘END{print NR}’ 8. Printing words of a line in reverse order awk '{for (i=NF;i>0;i--){ printf  "%s%s",$i,FS  } print "" }' 9. Printing lines of a file in Reverse order. awk ‘{ arr[NR]=$0...

Network Management a brief introduction

Network management has been very crucial technology due to the multivendor, multi-tenant and multi-serivice environment.Today, all the good telecom service provider, Internet service providers, and banks need to have very good management system to provide the better user experience and quality of service. Proper network management system ensures very less mean time to repair the service in case of failures in the network there by improving overall customer experience. This article makes you understand about the management system in very layman terms. 1. What is network management system? Network management system(NMS) is a combination of software and hardware used to administer and monitor the computer networks devices and networked applications.Unlike, element management system, NMS is concerned about how the network elements are tied up together in the environment, and the impacts one makes to the other.Today there are so many vendors which develop NMS so...

How To Configure a Simple VLAN Topology?

Image
Well, this article explains how to design and configure a simple VLAN topology.I use following topology to achieve the same. Objective: Design and configure the 3 VLANs each having single host as shown in the diagram. Following are the steps to configure above vlan topology: Step1: Select the IP address to suit the topology. As VLAN breaks the broadcast domain, we need to select three different subnets.In above topology, each subnet needs two IP addresses.Hence i select Class-C network & 255.255.255.252 as subnet mask.I know you might have already guessed the reason behind selecting that subnet mask.This mask allows you to configure only two IP addresses per subnet.What are the possible subnets?well, its easy! subtract last octet value from 256, which is basically 256-252=4.Now, make the block size of 4.Following are the possible subnets: 192.168.221.0,192.168.221.4,192.168.221.8,192.168.221.12 & so on. In each subnet lowest ip address is network address ...

Few great UNIX commands & useful links

Following are the some advanced UNIX commands which i found very useful. DNS (Domain Name Service) host string Perform forward or reverse lookup on string dig @nameserver string Lookup string's host info from nameserver System Hardware Information grep -i memtotal /proc/meminfo Find total amount of RAM in the system dmidecode -q Display DMI/SMBIOS information cat /proc/cpuinfo Display CPU information egrep '(vmx|svm)' /proc/cpuinfo See if a processor supports hardware virtualization lspci -tv Display PCI information lsusb -tv Display USB information hdparm -i /dev/sda Display disk information for sda Quick HTML Editing Site Wide find . -type f -print -exec sed -i -e 's|X|Y|g' {} \; Replace all X's with Y's in all files this directory and below. perl -pi -w -e 's/X/Y/g;' *.txt Replace all X's with Y's in all files ending with *.txt find -name '*' | xargs grep 'string' Print filename and all lines containing ...

An interview question in unix, which is asked by most of the companies

Well, i was asked a question(which was last one)  write a shell script which renames all *.txt files in a directory to *.sh ? Immediately, mv command came into my mind as it does in many peoples' mind.Then i wrote like: find . -name "*.txt" -exec mv *.txt *.sh {}\;  however this was wrong. He told me to explain how the above would work and i realized this was not correct. then i tried something else like: find . -name "*.txt" -exec ls {}\; | perl -e '`rename *.txt *.sh`' I wasn't pretty much sure that this would work.He told thats fine if i could  try without perl. I asked for some hints and he reminded me of xargs & sh.Then i tried like: find . -name "*.txt" -exec ls {}\;| xargs -n1 sh -c 'mv $1 `basename $1 .txt`.sh' - and then i got selected in the unix rounds... :-) :-)  xargs is really a great unix command like sed & awk.It is quite often used for parallel processing.Never miss this if you  like t...

Management software solutions in the industry

Well, this article doesn’t take you into any depth of management software solutions. However, this article gives a broad insight into the current industry trends in management software solutions. When we say a management system we are using very vague term in fact. There are many different management systems to achieve different goals. As per my knowledge so far the NMS software particularly meant to manage the devices from a single vender does have most of the FCAPS functionalities in it. Which means single software is used to achieve Configuration management, performance management, fault management & monitoring, Security management & Accounting management in few cases. However, the management software which supports multiple vendors may be different for different FCAPS functionalities. Suppose one software for Network monitoring for multiple vendor NEs(ex. EMC smarts), one for Configuration management for multiple vendor NEs(Ex. HP openView), one for performance man...