Skip to main content

AWK one liners [part two]

contd..


Here is a sample csv file












1. Print columns from a csv file 


awk -F "," '{print $1}' abc.csv










awk -F "," '{print $1 "    " $3}' abc.csv










Where -F defines the seperator.


There is an alternate method to use the field separator









Here FS is used to define the filed separator which is “,” in 

this case it could be a whitespace , a tab etc.



2. Display Content of the file without displaying header


awk 'NR!=1 {print $1 "    " $2}' abc.txt











awk 'NR>2 {print $1 "    " $2}' abc.txt











Where NR indicates the row number



3. Saving AWK output to a separate file







Comments

Popular posts from this blog

Ubuntu Xrdp installation with Mate Desktop

The process for installation of Mate Desktop along with Xrdp on Ubuntu is as follows:  1. Update Repository      sudo apt update 2. Upgrade Ubuntu         Note: If asked to override PAM configuration, select No (and make         sure to select correct boot drive if requested)      sudo apt upgrade 3. Set iptables rules      sudo iptables -A INPUT -p tcp --dport 3389 -j ACCEPT      sudo iptables-save | sudo tee -a /etc/iptables/rules.v4      sudo reboot 4. Install xrdp and Mate Desktop      sudo apt install libgl1-mesa-dri fonts-dejavu mate-session-manager \      mate-panel marco caja mate-terminal mate-applet-brisk-menu \      mate-dock-applet mate-indicator-applet mate-indicator-applet-common \      ubuntu-mate-icon-themes mate-applets-common plank \      mate-hud mate-menu mate-apple...

Solaris Installation From FLAR [FLASH ARCHIVE]

login as: username Password: user@hostname:~$ user@hostname:~$ user@hostname:~$ user@hostname:~$ su - Password: Oracle Corporation       SunOS 5.11       11.2     November 2019 You have new mail. user@hostname:~# bash user@hostname:~# #LIST THE DOMAINS ON BASE MACHINE root@hostname:~# ldm list NAME             STATE       FLAGS   CONS     VCPU   MEMORY   UTIL   NORM   UPTIME primary           active     -n-cv-   UART     32     64G       0.3%   0.3%   139d 13h hostname-AI-REPO active     -n----   5001     16     32G       0.1%   0.1%   139d 13h hostname-LD02 active     -n----   5002     32     32G       0.0%   0.0%   15m hostname-LD03 bound       ------...

Ldom Backup & Restore

1. Login to control Domain and list the current configuration file. bash-3.2# ldm list-spconfig basic_configuration new_configuration [current] 2.To take the complete LDOM configuration backup use below command. # ldm list-constraints -x >config.xml 3.You can also  take the configuration backup for specific LDOM # ldm list-constraints -x ldom_name > ldom_name.xml How to restore the system to factory default  1. Login to the control domain console and remove the spconfig profile. bash-3.2# ldm ls-spconfig basic_configuration new_configuration[current] bash-3.2# ldm  remove-spconfig new_configuration bash-3.2# ldm ls-spconfig basic_configuration [next poweron] 2.Power cycle the server to take the changes effect. bash-3.2# init 5 -> show /SYS   Properties:         type = Host System         ipmi_name = /SYS         keyswitch_state...