AWK SCRIPTING
Adding sth to a file
$NF is the value of the last field in the line in awk , $NF-1 is the last but one field
$0 is the entire line
grep PIN FB_041509_newpins.lef
awk '{print $2 "()"}' this command greps all lines with PIN and
selects $2 only and writes to new file and adds () after $2 in every line
awk '{print $2 "()"}
awk '/PIN/ {print $1 $2}' filename ==> prints the output with $1 and $2 values side by side w/o any space
awk '/PIN/ {print $1,$2}' filename ==> prints the output with $1 and $2 values side by side with space
OR
awk '/PIN/ {print $1 " " $2}' filename ==> prints the output with $1 and $2 values side by side with space
awk '/foo/ { print $0 }' /etc/passwd this is command searches for foo in file passwd and prints the entire line having foo
awk '/start/, /stop/' file # Print all lines between start/stop pairs (not working)
awk '{print ; print ""}' FB_041509_newpins.lef to include line spaces between lines in a file
{ printf("The sum on line %d is %.0f.\n", NR, $1+$2) } in awk
awk '{ printf("the port of FB of %d is %f \n", NR, $2) }' FB_041509_newpins.lef
NR is the number of lines print NF prints all the line nos one by one in file
NF is the no of fields in a line and (print NF) prints all the fields of each line one by one
awk '/PIN/ {print $1; print $2}' FB_041509_newpins.lef prints $1 in one line and $2 in next line
awk '$1~/^C/' test.sp line beginning with C
PIN vcc after grep or search for PIN (the same line having PIN)
PIN vdd
OUTPUT is like this
PIN
vcc
PIN
vdd
awk '{print "-" " "$1 " " "il_biobuf_assp" " " "+" " " "PLACED" " " "(" " " $2 " "$3 " " ")" " " "S" }' newpadfile > compfile
awk '{print ; print " " ";"}' compfile > compfile_total ==> this command inserts ; in the every nextline of file compfile
egrep "Layout Primary Cell:
TOTAL DRC Results Generated:" oan211d2.report
awk '{ cell = $NF;getline;print cell,$(NF-1),$NF;}'
==============AWK GETLINE=================
AWK getline is important and used when we want to print the output by operating on more than one line
awk '{cell = $NF; getline;name = $4; getline;print cell,name,$3}' testfile ==> this command reads NF, $4 and $3 words from three different lines of the file testfile
IN the above command getline will get the next line in the file
awk '{ cell = $NF;getline;print cell,$(NF-1),$NF;}'
=====================================VI COMMANDS===========================================
No comments:
Post a Comment