Sponsored Content
Top Forums Shell Programming and Scripting How to define a variable in a BASH script by using a JSON file online? Post 302869185 by cjcox on Tuesday 29th of October 2013 06:43:19 PM
Old 10-29-2013
To do so generically might be beyond even bash variables. But you could always smash the paths, just might have to have counters for multiple contructs at a level... so you might have

Code:
latest_0_snapsthot='1.7.2'
latest_0_release='1.7.2'

Might not be horrible writing something in awk or sed to produce this type of output so it can be sourced into a program. Due to the counters, awk is the better candidate.

In your case, it could be very simple if you are just needing the one thing though. Just pull the line out, and do a simple translate.

(I guess I'm trying to push you toward a solution without handing one to you)
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

2. Shell Programming and Scripting

bash - define a variable

Hello, I would like to define a variable based on another variable: a=5 b$a=100 This does not work. What is the right way to do it? Thanks ---------- Post updated at 07:37 PM ---------- Previous update was at 07:33 PM ---------- Found my answer with the search function (did not... (0 Replies)
Discussion started by: jolecanard
0 Replies

3. Shell Programming and Scripting

question about define variable.

Hi, Unix Gurus, In our existing file, there is a script like #!/bin/sh step=${1:-0} cur_step=10 if ... My question is what's "${1:-0}" mean? I know it defines a variable but I don't know what's (1:-0) mean? :wall: Thanks in advance. (2 Replies)
Discussion started by: ken002
2 Replies

4. Shell Programming and Scripting

Define variable from file.

HI I have file A.txt _1A _2A _3A _4A I want define all as different variable. $1A=_1A $2B=_2A $3C=_3A $4D=_4A Now i can use any variable in my script. (3 Replies)
Discussion started by: pareshkp
3 Replies

5. Shell Programming and Scripting

Bash script - cygwin (powershell?) pull from GitHub API Parse JSON

All, Have a weird issue where i need to generate a report from GitHub monthly detailing user accounts and the last time they logged in. I'm using a windows box to do this (work issued) and would like to know if anyone has any experience scripting for GitAPI using windows / cygwin / powershell?... (9 Replies)
Discussion started by: ChocoTaco
9 Replies

6. Shell Programming and Scripting

How to define two digits variable in shell script?

Dear Shell script Experts, I am working on shell script which is defined here, qsub_seq.csh . The purpose of this script is to read few input files (with defined starting index and last index) and make processing faster over server. For some task, I had 1064 of input files, so I wrote another... (8 Replies)
Discussion started by: emily
8 Replies

7. Shell Programming and Scripting

Parsing and Editing a json file with bash script

I am trying to automate editing of a json file using bash script. The file I initially receive is { "appMap": { "URL1": { "name": "a" }, "URL2": { "name": "b" }, "URL3": { "name": "c" }, } WHat I would like to do is replace... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

8. Shell Programming and Scripting

JSON structure to table form in awk, bash

Hello guys, I want to parse a JSON file in order to get the data in a table form. My JSON file is like this: { "document":{ "page": }, { "column": } ] }, { ... (6 Replies)
Discussion started by: Gescad
6 Replies

9. Shell Programming and Scripting

Building JSON command with bash script

Hello. I'm new to bash script and I'm learning the basics by writing some scripts. Recently a friend of mine asked me if I could try to write a script to him to automate a couple of processes that uses JSON RPCs. I'll try to explain in few words the workflow just to contextualize the problem.... (48 Replies)
Discussion started by: psysc0rpi0n
48 Replies
smd-config(5)						 Sync Mail Dir (smd) documentation					     smd-config(5)

NAME
smd - configuration file for smd-pull and smd-push GENERAL SETUP
To generate a template config file run smd-pull(1) with the -t option. If no endpoint is specified, the configuration file is named ~/.smd/config.default, otherwise it is named ~/.smd/config.endpoint. That file is composed by the following fields CLIENTNAME name of the client host SERVERNAME name of the server host MAILBOX list of directories, separated by space The field SERVERNAME must be a valid name for ssh, thus can be an alias like smd-server-foo. The default configuration file contains an example of how to set up an alias for ssh. The field CLIENTNAME is just an ID for the local host. If you plan to sync the same host with multiple remote hosts, you MUST use different values for CLIENTNAME for every configuration file. The field MAILBOX is a space separated list or roots that will be scanned for maildirs. Typically it is just one directory name, Mail or Maildir. The roots must be paths relative to the home directory. In the simplest case, the roots are named the same on both the local and the remote hosts. If the roots have different names on the local and remote hosts, but their internal structure is the same, the simplest solution is to just use a symlink on one of the two hosts so that a single name can be used to refer to both. If the internal sub folder structure differ, for example because on the remote hosts sub folders names are prefixed with a dot but it is not the case on the local one, refer to the MAIL FOLDER RENAMING section of this document. The configuration file is a regular shell script, refer to bash(1) for its syntax. HOOKS
The content of the directories ~/.smd/hooks/{pre,post}-pull.d/ is executed respectively before and after smd-pull does it's job. They receive four arguments: "pre" or "post", "pull", the endpoint name and the status. The status is always 0 (meaning success) for pre hooks, while can be 1 (for failure) for post hooks. Hooks should not fail, if they do so then smd-pull will fail too. The content of the directories ~/.smd/hooks/{pre,post}-push.d/ is executed respectively before and after smd-push does it's job. They receive four arguments: "pre" or "post", "push", the endpoint name and the status. The status is always 0 (meaning success) for pre hooks, while can be 1 (for failure) for post hooks. Hooks should not fail, if they do so then smd-push will fail too. MAIL FOLDER RENAMING
To make the transition from other synchronization tools smooth, the folders structure on the local and remote host are allowed to differ. For example, offlineimap usually removes trailing dots from the names of sub folders. To take advantage of folder renaming, the configuration file can contain the following fields: MAILBOX_LOCAL the local roots of maildirs MAILBOX_REMOTE the remote roots of maildirs TRANSLATOR_RL a program to translate remote mailbox names to local ones TRANSLATOR_LR a program to translate local mailbox names to remote ones The fields MAILBOX_LOCAL and MAILBOX_REMOTE must substitute the MAILBOX fields explained above. The fields TRANSLATOR_RL and TRANSLATOR_LR must define two translator programs that will be run to translate remote mailbox names to local ones (TRANSLATOR_RL) and vice versa (TRANSLATOR_LR). A translator program must fulfil the following requirements: o must be an absolute path or relative to the $HOME directory or in the user $PATH and must be executable o receives in standard input one or more paths starting with one of the roots listed in MAILBOX_LOCAL (for TRANSLATOR_LR) or MAIL- BOX_REMOTE (for TRANSLATOR_RL) and ending with cur, new or tmp o it can fail, returning 1 and writing on standard output the string ERROR followed by a new line and a human readable error message in the following lines o it can succeed, returning 0 and printing on standard output the corresponding translated paths PATHS EXCLUSION
In case some paths need to be skipped, they can be specified as space separated glob(7) expressions in the variable: EXCLUDE glob expressions identifying paths to be excluded Note that these expressions must match real paths, no translation operation is applied to them, so it may be necessary to specify different expressions for the local and remote endpoint. In that case the following variables can be set: EXCLUDE_LOCAL glob expressions identifying local paths to be excluded EXCLUDE_REMOTE glob expressions identifying remote paths to be excluded Matching is performed using fnmatch(3) with no special flags, thus `*' and `?' match any character including `/'. Last, note that spaces in glob expressions must be replaced by %20. For example, to exclude all paths matching the expression `Mail/delayed [1-5] days/*' the vari- able EXCLUDE must be set to `Mail/delayed%20[1-5]%20days/*' Last, matching is performed every time a directory is entered, and if the matching succeeds the directory and all its subdirectories are skipped. Thus there is no need to specify a trailing '/*' in every expression. LOCAL SYNCHRONIZATION
If the local and remote mailboxes are on the same host the following option must be added to the configuration file: SMDCLIENTOPTS=-l Note that this options has also the effect that ssh is not used. A a simple pair of pipes is used instead. DELETIONS
In some cases, usually unidirectional synchronizations, one may want to not propagate deletions. E.g. one keeps a slim working mailbox but pushes to a backup mailbox to save every email. For that scenario smd-pull and smd-push accept a -n, --no-delete, option. To avoid speci- fying this option every time one can put it in the configuration file: SMDSERVEROPTS=-n FILES
~/.smd/config.* ~/.smd/hooks/pre-pull.d/ ~/.smd/hooks/post-pull.d/ ~/.smd/hooks/pre-push.d/ ~/.smd/hooks/post-push.d/ SEE ALSO
mddiff(1), smd-server(1), smd-client(1), smd-push(1), smd-loop(1), smd-translate(1) AUTHOR
Enrico Tassi <gares@fettunta.org> 11 June 2012 smd-config(5)
All times are GMT -4. The time now is 05:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy