The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: AWK program
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-09-2009
ripat ripat is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2006
Location: Belgium
Posts: 438
Code:
BEGIN {
	FS="[ .]"
}

/GH[12]/ {
	str = $1=="GH1" ? "The world is round" : "Today is my birthday"
	printf "%s %s.%s.%.1s\n", str, $2, $3, $4
}
Or the same as a one-liner:
Code:
awk -F'[ .]' '/GH[12]/ {str=$1=="GH1"?"The world is round":"Today is my birthday";printf "%s %s.%s.%.1s\n",str,$2,$3,$4}' your.file