Site Map - skip to main content - dyslexic font - mobile - text - print

Hobby Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.


Please support our Patrons

Our hosting is kindly provided by Josh from AnHonestHost.com. We would appreciate it if you could donate to help reduce his costs in funding the hosting. He is also accepting bitcoins to 1KsxJr9HtsdaUeU7yaV9bk9bQi21UPBtUq
Please also consider supporting the https://archive.org/donate/ who are now hosting our media files. Right now, a generous supporter will match your contributions 3-to-1. So your $5 donation results in $20 for the Internet Archive.

hpr2554 :: Gnu Awk - Part 11

In part 11 of the series, we string and number built-in functions

<< First, < Previous, Latest >>

Host Image
Hosted by b-yeezi on 2018-05-17 is flagged as Clean and is released under a CC-BY-SA license.
Tags: bash, linux, awk.
Listen in ogg, spx, or mp3 format. | Comments (0)

Part of the series: Learning Awk

Episodes about using Awk, the text manipulation language. It comes in various forms called awk, nawk, mawk and gawk, but the standard version on Linux is GNU Awk (gawk). It's a programming language optimised for the manipulation of delimited text.

Awk Part 11

Gnu Awk Documentation: https://www.gnu.org/software/gawk/manual/gawk.html#String-Functions

Numerical functions

  • atan2: arctangent of y / x in randians
  • cos: cosine of x in radians
  • exp: ex
  • int: floor float to int
  • log: natrual log
  • randn: (pseudo) random number between 0 and 1
  • sin: sine of x in radians
  • sqrt: square root
  • srand: (pseudo) random between 0 and 1, manually setting the seed

String functions

  • asort: array sort. Returns array with the values sorted
  • asori: array sort. Returns array with the keys (index) sorted
  • gensub: Search the target string target for matches of the regular expression regexp. Returns string with substituted text.
  • gsub: Search target for all of the longest, leftmost, nonoverlapping matching substrings it can find and replace them with replacement. Returns string with substituted text.
  • sub: Search target, which is treated as a string, for the leftmost, longest substring matched by the regular expression regexp. Returns string with substituted text.
  • index: Search the string in for the first occurrence of the string find. Returns the position where that occurence begins
  • length: returns length of string
  • match: Search string for the longest, leftmost substring matched by the regular expression regexp and return the character position (index) at which that substring begins.
  • split: Divide string into pieces delimted by field separator. Returns an array of strings
  • sprintf: Allows you to store the a string in the that would have been the output of printf into a variable
  • strtonum: Turn octal representation to number
  • substr: Substring starting at position x for length of y. Returns string
  • tolower: Lower-case the string
  • toupper: Upper-case the string

References


Comments

Subscribe to the comments RSS feed.

<< First, < Previous, Latest >>

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Title:
Comment:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?