Skip to content

deverl/inireader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inireader

This command line program just reads a named value from a section in an ini file.

usage: inireader <path-to-ini-file> <section-name> <value-name>

For example, if the ini file was as shown here:


  ; File: sample.ini
  ;
  ; This is just the sample ini file used for testing inireader.
  
  [USER]
  username = "John Somebody"
  email = "somebody@domain.com"
  acl = 923784
  
  [CLIENT]
  name = "Acme Trucking"
  this is just some random junk that shouldn't be read by the parser.
  phone = "555-555-1212"
  city = "Boise"
  state = "ID"
  zip = "83713"

You could read the client's phone number using this command:

$ inireader sample.ini  CLIENT  phone

Both the section name and the key name comparisons disregard differences in case, so all of the following would work also:

$ inireader sample.ini  client  phone
$ inireader sample.ini  client  PHONE
$ inireader sample.ini  CLIENT  PHONE

The phone number would be printed on the terminal

Use in a Script

To read a value into a shell variable, you could use

USERNAME=$(inireader sample.ini client username)

About

Command line ini reader program

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published