Sponsored Content
Top Forums Shell Programming and Scripting Shell script to read specified value from file and echo to the same location to other file. Post 302915078 by ausdim on Sunday 31st of August 2014 09:10:22 AM
Old 08-31-2014
Lightbulb Shell script to read specified value from file and echo to the same location to other file.

Hello.
I want to to backup some "default:" values from a file do some other job and after restore that "default:" values back.

The problem is that the source and destination file has a lot of default: strings in it but with different values...

So..
Here is an example:

A part of my source file named "config.json".

Code:
    { SPane:{ 
        title:"Blinking effect",
        description:"Control the way the LED blinks."
    }},
    { SCheckBox:{
        description:"Completely disable led notifications.", 
        label:"Disable LED",
        default:0,
                action:"generic /sys/class/sec/led/led_completely_disable"
    }},
    { SCheckBox:{
        description:"If disabled, the controller bypasses slope generation.", 
        label:"Enable LED fading",
        default:1,
                action:"generic /sys/class/sec/led/led_fade"
    }},
    { SSeekBar:{
        title:"Fade-in time period",
        description:"Sets the time period of the rising slope.",
        min:0, max:12, unit:"ms", step:1,
        default:2,
                action:"generic /sys/class/sec/led/led_fade_in_time"
    }},
    { SSeekBar:{
        title:"Fade-out time period",
        description:"Sets the time period of the falling slope.",
        min:0, max:20, unit:"ms", step:1,
        default:8,
                action:"generic /sys/class/sec/led/led_fade_out_time"
    }},

With the code:
Code:
echo "$(cat config.json | grep default: | awk -F default '{print $2 }' | awk -F , '{print $1 }')" > def;

This it will output all default values to "def" file.
Like:
Code:
:0
:1
:2
:8

Note that some values also have strings in it...

So after some other commands the source file change those default values and simply Smilie i want to restore those values from "def" file to "config.json" file.

Wish to explain it ok.

Thanks

Last edited by ausdim; 08-31-2014 at 01:58 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need shell script to read two file at same time and print out in single file

Need shell script to read two file at same time and print output in single file Example I have two files 1) file1.txt 2) file2.txt File1.txt contains Aaa Bbb Ccc Ddd Eee Fff File2.txt contains Zzz Yyy Xxx (10 Replies)
Discussion started by: sreedhargouda
10 Replies

2. Shell Programming and Scripting

how to read dbf file in shell script and to convert dbf file usinf shell script

Hi all, I am new to shell scripting. I have dbf file and I need to convert it into csv file. OR, can i read the fields from a .dbf file and OR seprate the records in dbf file and put into .csv or txt. Actually in the .dbf files I am getting , the numbers of fields may vary in very record and... (6 Replies)
Discussion started by: gauara
6 Replies

3. Shell Programming and Scripting

Bash script to read file location

I'm writing a bash script that reads a file location from a user, and I'm wondering how to get the script to accept tab to auto complete the directories that are input. (8 Replies)
Discussion started by: Prodiga1
8 Replies

4. Shell Programming and Scripting

Write shelll script to read file location

hi all i have a problem how to read file location..I read file as FILE=/home/tmp/new.file.but t is not useful for me.But i want my script read file location where the file is and copy in directory at boot time. Every time of booting files are copied in respective folder.please help !!!!:) (2 Replies)
Discussion started by: shubhig15
2 Replies

5. Shell Programming and Scripting

echo ls to a file and then read file and selectively delete

I'm trying to write a script that will do an ls of a location, echo it into a file, and then read that file and selectively delete files/folders, so it would go something like this: cd $CLEAN_LOCN ls >>$TMP_FILE while read LINE do if LINE = $DONTDELETE skip elseif LINE =... (2 Replies)
Discussion started by: MaureenT
2 Replies

6. Shell Programming and Scripting

shell script to add input at certain location into a file

Hi, I am using Solaris 10 OS and trying to create shell script that can add input at certain location into a file. The input that I am trying to put is new domain name e.g @newdomain.com the file contains, more test01.out user/zzzz786@st.com/INBOX user/zzzz@po.com/INBOX... (8 Replies)
Discussion started by: Mr_47
8 Replies

7. Shell Programming and Scripting

Shell script to read file and check file type

Hi, I have a file with few values in it. I need script help to read file line by line and check: 1/if it's a file (with extension eg .java .css .jar etc ) or 2/if it's a file without extension and treat it as a directory and then check if the directory exists in working copy else create one... (6 Replies)
Discussion started by: iaav
6 Replies

8. Shell Programming and Scripting

How to read each line from input file, assign variables, and echo to output file?

I've got a file that looks like this (spaces before first entries intentional): 12345650-000005000GL140227 ANNUAL HELC FEE EN 22345650-000005000GL140227 ANNUAL HELC FEE EN 32345650-000005000GL140227 ANNUAL HELC FEE EN I want to read through the file line by line,... (6 Replies)
Discussion started by: Scottie1954
6 Replies

9. Shell Programming and Scripting

File transfer from UNIX to shared location using shell script

Is there any possible way transfering the file from unix to shared location using shell script. i had created the batch script to fetch the files from unix to shared location and it works fine. Due to some problem in windows unable to transfer the file to shared location automatically. can anyone... (2 Replies)
Discussion started by: venkat918
2 Replies

10. UNIX for Beginners Questions & Answers

Shell Script to Read the given file contents into a merged one file

Like to have shell script to Read the given file contents into a merged one file with header of path+file name followed by file contents into a single output file. While reading and merging the file contents into a single file, Like to keep the format of the source file. ... (4 Replies)
Discussion started by: Siva SQL
4 Replies
LED(4)							   BSD Kernel Interfaces Manual 						    LED(4)

NAME
led -- API for manipulating LED's, lamps and other annunciators SYNOPSIS
#include <dev/led/led.h> typedef void led_t(void *priv, int onoff); struct cdev * led_create_state(led_t *func, void *priv, char const *name, int state); struct cdev * led_create(led_t *func, void *priv, char const *name); void led_destroy(struct cdev *); DESCRIPTION
The led driver provides generic support for handling LEDs, lamps and other annunciators. The hardware driver must supply a function to turn the annunciator on and off and the device name of the annunciator relative to /dev/led/. The priv argument is passed back to this on/off function and can be used however the hardware driver sees fit. The lamp can be controlled by opening and writing ASCII strings to the /dev/led/bla device. In the following, we will use this special notation to indicate the resulting output of the annunciator: * The annunciator is on for 1/10th second. _ The annunciator is off for 1/10th second. State can be set directly, and since the change happens immediately, it is possible to flash the annunciator with very short periods and syn- chronize it with program events. It should be noted that there is a non-trivial overhead, so this may not be usable for benchmarking or mea- suring short intervals. 0 Turn the annunciator off immediately. 1 Turn the annunciator on immediately. Flashing can be set with a given period. The pattern continues endlessly. f _* f1 _* f2 __** f3 ___*** ... f9 _________********* Three high-level commands are available: d%d Numbers. Each digit is blinked out at 1/10th second, zero as ten pulses. Between digits a one second pause and after the last digit a two second pause after which the sequence is repeated. s%s String. This gives full control over the annunciator. Letters 'A' ... 'J' turn the annunciator on for from 1/10th to one full second. Letters 'a' ... 'j' turn the annunciator off for 1/10th to one full second. Letters 'u' and 'U' turn the annunciator off and on respectively when the next UTC second starts. Unless terminated with a '.', the sequence is immediately repeated. m%s Morse. '.' becomes '_*' '-' becomes '_***' ' ' becomes '__' ' ' becomes '____' The sequence is repeated after a one second pause. FILES
/dev/led/* EXAMPLES
A 'd12' flashes the lamp *__________*_*______________________________ A 'sAaAbBa' flashes *_*__**_ /usr/games/morse -l "Soekris rocks" > /dev/led/error SEE ALSO
morse(6) HISTORY
The led driver first appeared in FreeBSD 5.2. AUTHORS
This software was written by Poul-Henning Kamp <phk@FreeBSD.org>. This manual page was written by Sergey A. Osokin <osa@FreeBSD.org> and Poul-Henning Kamp <phk@FreeBSD.org>. BSD
April 24, 2007 BSD
All times are GMT -4. The time now is 03:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy