Sponsored Content
Top Forums Shell Programming and Scripting Storing command output in a variable and using cut/awk Post 302913995 by rbatte1 on Thursday 21st of August 2014 09:17:59 AM
Old 08-21-2014
JustALol,
I think you are trying to over work this and have confused it trying to make it neat. Would this do?:-
Code:
md5sum file1 | read newvar filename
print $newvar

What is the intention with this? If you are looking to store the value long term and then check for unauthorised changes, then md5sum allows you to read a file containing the hashes and compare them:-
Code:
echo "Original file" > my_test_file
for file in *
do
   md5sum $file
done > /tmp/my_hashes

echo "Changed file" > my_test_file
md5sum -c /tmp/my_hashes

Does that work with what you are really intending to do?



Robin

Last edited by rbatte1; 08-21-2014 at 10:18 AM.. Reason: Addressed to JustALol, not Franklin52
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

storing output of awk in variable

HI I am trying to store the output of this awk command awk -F, {(if NR==2) print $1} test.sr in a variable when I am trying v= awk -F, {(if NR==2) print $1} test.sr $v = awk -F, {(if NR==2) print $1} test.sr but its not working out . Any suggestions Thanks Arif (3 Replies)
Discussion started by: mab_arif16
3 Replies

2. UNIX for Dummies Questions & Answers

Storing the output into a variable

Hi unix gurus, I am trying to store the result of a command into a variable. But it is not getting stored. x='hello' y=echo $x | wc -c but it is giving the output as 0(zero) Pls help me its very urgent (7 Replies)
Discussion started by: ravi raj kumar
7 Replies

3. UNIX Desktop Questions & Answers

problem while storing the output of awk to variable

Hi, i have some files in one directory(say some sample dir) whose names will be like the following. some_file1.txt some_file2.txt. i need to get the last modified file size based on file name pattern like some_ here i am able to get the value of the last modified file size using the... (5 Replies)
Discussion started by: eswarreddya
5 Replies

4. Shell Programming and Scripting

storing output from echo & cut into variable

Hi All, Hope someone can advise here as I have been struggling to find a syntax that works here. I have tried a stack of combination I have seed in the forums but I think because I have needed to use "" and `` in the statments another method is found. I am reading in lines with the following... (1 Reply)
Discussion started by: nkwilliams
1 Replies

5. Shell Programming and Scripting

Storing output of "time" command to a variable

Hi all, I am new to Linux/shell scripting having moderate knowledge. In my script, I need to get execution time of a command (say 'ls') in mili seconds level. For this i tried using "time" command to retrieve the total execution time in milli seconds. But, the problem is that, how to save... (9 Replies)
Discussion started by: happening_linux
9 Replies

6. Shell Programming and Scripting

Storing output into a variable

My script below seems to be choking because I need the the output of the find command to be stored as a variable that can then be called by used lower in the script. #!/bin/bash cd "/resumes_to_be_completed" var1=find . -mmin -1 -type f \( -name "*.doc" -o -name "*.docx" \)... (1 Reply)
Discussion started by: binary-ninja
1 Replies

7. Shell Programming and Scripting

Storing awk command in a variable

I'm working on a script in which gives certain details in its output depending on user-specified options. So, what I'd like to do is something like: if then awkcmd='some_awk_command' else awkcmd='some_other_awk_command' fi Then, later in the script, we'd do something like: ... (5 Replies)
Discussion started by: treesloth
5 Replies

8. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

9. Shell Programming and Scripting

Storing multiple sql queries output into variable by running sql command only once

Hi All, I want to run multiple sql queries and store the data in variable but i want to use sql command only once. Is there a way without running sql command twice and storing.Please advise. Eg : Select 'Query 1 output' from dual; Select 'Query 2 output' from dual; I want to... (3 Replies)
Discussion started by: Rokkesh
3 Replies

10. Shell Programming and Scripting

Use cut output as variable piped awk command

Hi, I would like use the output of my cut command as a variable in my following awk command. Here's what I've written. cut -f1 info.txt | awk -v i=xargs -F'' '{if($6 == $i) print $20}' summary.txt Where obviously the 'xargs' doesn't do what I want. How can I pass my cut result to my awk... (3 Replies)
Discussion started by: heyooo
3 Replies
Log::Handler::Config(3pm)				User Contributed Perl Documentation				 Log::Handler::Config(3pm)

NAME
Log::Handler::Config - The main config loader. SYNOPSIS
use Log::Handler; my $log = Log::Handler->new(); # Config::General $log->config(config => 'file.conf'); # Config::Properties $log->config(config => 'file.props'); # YAML $log->config(config => 'file.yaml'); Or use Log::Handler; my $log = Log::Handler->new(); $log->config( config => 'file.conf' plugin => 'YAML', ); DESCRIPTION
This module makes it possible to load the configuration from a file. The configuration type is determined by the file extension. It's also possible to mix file extensions with another configuration types. PLUGINS
Plugin name File extensions ------------------------------------------ Config::General cfg, conf Config::Properties props, jcfg, jconf YAML yml, yaml If the extension is not defined then "Config::General" is used by default. METHODS
config() With this method it's possible to load the configuration for your outputs. The following options are valid: config With this option you can pass a file name or the configuration as a hash reference. $log->config(config => 'file.conf'); # or $log->config(config => \%config); plugin With this option it's possible to say which plugin you want to use. Maybe you want to use the file extension "conf" with "YAML", which is reserved for the plugin "Config::General". Examples: # this would use Config::General $log->config( config => 'file.conf' ); # this would force .conf with YAML $log->config( config => 'file.conf', plugin => 'YAML' ); section If you want to write the configuration into a global configuration file then you can create a own section for the logger: <logger> <file> filename = file.log minlevel = emerg maxlevel = warning </file> <screen> minlevel = emerg maxlevel = debug </screen> </logger> <another_script_config> foo = bar bar = baz baz = foo </another_script_config> Now your configuration is placed in the "logger" section. You can load this section with $log->config( config => 'file.conf', section => 'logger', ); # or if you load the configuration yourself to %config $log->config( config => \%config, section => 'logger', ); # or just $log->config( config => $config{logger} ); PLUGINS
Config::General - inspired by the well known apache config format Config::Properties - Java-style property files YAML - optimized for human readability EXAMPLES
Config structures A very simple configuration looks like: $log->config(config => { file => { alias => 'file1', filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', } }); Now, if you want to add another file-output then you can pass the outputs with a array reference: $log->config(config => { file => [ { alias => 'file1, filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, { alias => 'file2', filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } ], screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); It's also possible to pass the outputs as a hash reference. The hash keys "file1" and "file2" will be used as aliases. $log->config(config => { file => { file1 => { filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, file2 => { filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); If you pass the configuration with the alias as a hash key then it's also possible to pass a section called "default". The options from this section will be used as defaults. $log->config(config => { file => { default => { # defaults for all file-outputs mode => 'append', }, file1 => { filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, file2 => { filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); Examples for the config plugins Config::General <file> alias = file1 fileopen = 1 reopen = 1 permissions = 0640 maxlevel = info minlevel = warn mode = append timeformat = %b %d %H:%M:%S debug_mode = 2 filename = example.log message_layout = '%T %H[%P] [%L] %S: %m' </file> Or <file> <file1> fileopen = 1 reopen = 1 permissions = 0640 maxlevel = info minlevel = warn mode = append timeformat = %b %d %H:%M:%S debug_mode = 2 filename = example.log message_layout = '%T %H[%P] [%L] %S: %m' </file1> </file> YAML --- file: alias: file1 debug_mode: 2 filename: example.log fileopen: 1 maxlevel: info minlevel: warn mode: append permissions: 0640 message_layout: '%T %H[%P] [%L] %S: %m' reopen: 1 timeformat: '%b %d %H:%M:%S' Or --- file: file1: debug_mode: 2 filename: example.log fileopen: 1 maxlevel: info minlevel: warn mode: append permissions: 0640 message_layout: '%T %H[%P] [%L] %S: %m' reopen: 1 timeformat: '%b %d %H:%M:%S' Config::Properties file.alias = file1 file.reopen = 1 file.fileopen = 1 file.maxlevel = info file.minlevel = warn file.permissions = 0640 file.mode = append file.timeformat = %b %d %H:%M:%S file.debug_mode = 2 file.filename = example.log file.message_layout = '%T %H[%P] [%L] %S: %m' Or file.file1.alias = file1 file.file1.reopen = 1 file.file1.fileopen = 1 file.file1.maxlevel = info file.file1.minlevel = warn file.file1.permissions = 0640 file.file1.mode = append file.file1.timeformat = %b %d %H:%M:%S file.file1.debug_mode = 2 file.file1.filename = example.log file.file1.message_layout = '%T %H[%P] [%L] %S: %m' PREREQUISITES
Carp Params::Validate EXPORTS
No exports. REPORT BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. If you send me a mail then add Log::Handler into the subject. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-11-21 Log::Handler::Config(3pm)
All times are GMT -4. The time now is 08:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy