Is there still any reason to learn AWK?

If you quickly learn the basics of awk, you can indeed do amazing things on the command line. But the real reason to learn awk is to have an excuse to read the superb book The AWK Programming Language by Aho, Kernighan, and Weinberger. The AWK Programming Language at archive.org You would think, from the … Read more

How to escape a single quote inside awk

This maybe what you’re looking for: awk ‘BEGIN {FS=” “;} {printf “‘\”%s’\” “, $1}’ That is, with ‘\” you close the opening ‘, then print a literal ‘ by escaping it and finally open the ‘ again.

Get last field using awk substr

Use the fact that awk splits the lines in fields based on a field separator, that you can define. Hence, defining the field separator to / you can say: awk -F “https://stackoverflow.com/” ‘{print $NF}’ input as NF refers to the number of fields of the current record, printing $NF means printing the last one. So … Read more

How to print matched regex pattern using awk?

This is the very basic awk ‘/pattern/{ print $0 }’ file ask awk to search for pattern using //, then print out the line, which by default is called a record, denoted by $0. At least read up the documentation. If you only want to get print out the matched word. awk ‘{for(i=1;i<=NF;i++){ if($i==”yyy”){print $i} … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)