Sponsored Content
Top Forums Shell Programming and Scripting Using the part of a line as a variable? Post 302569083 by rpf on Saturday 29th of October 2011 09:58:14 AM
Old 10-29-2011
I have some ideas but have no script knowledge Smilie

do you know how to pick a part of a line ?

I think if we pick the part of line we can define it as a variable (say WAY) and use it in a script in my bin as

here the code for picking the part of line
cd $WAY


can we ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh: A part of variable A's name is inside of variable B, how to update A?

This is what I tried: vara=${varb}_count (( vara += 1 )) Thanks for help (4 Replies)
Discussion started by: pa3be
4 Replies

2. Shell Programming and Scripting

Repacing part of string with a variable

I have following strings in a file DUPTASMTRMMBAL,20070416200704160117232101172321,,,,,,,@@@Y DUPTASMTRMMCON,20070416200704160127189901271899,,,,,,,@@@Y DUPTASMTRMMHG,,20070416200704160112051001120510,,,,,,,@@@Y What i need to do is replace the date 20070416 with anoth date which is stored in... (4 Replies)
Discussion started by: divz
4 Replies

3. Shell Programming and Scripting

Copy part of a variable

Hi, i was using a input file to get the last line of the file.But now i have stored the values from the file to a variable and want the last line from the variable . Slightly confused on how to extract that data from the variable. previous code, cat input.txt <TIME>00:15:48</TIME>... (2 Replies)
Discussion started by: Shellslave
2 Replies

4. Shell Programming and Scripting

Variable of Content From Part of Other File

I may not being doing this description justice, but I'll give it a try. I created a mailx script; there will be several messages using the same script where the only difference is the content. So I figured I'd make the content of the message a variable retrieved from a separate file. I have five... (5 Replies)
Discussion started by: royarellano
5 Replies

5. Shell Programming and Scripting

How read the part of the string into a variable?

Hi, I'm using bash and brand new to shell script. I would like to do the following. I have a string which is "UPDATE=1.0". I would like to read the value "1.0" alone in a variable. i.e the things afer "=" How do I do that? Thanks, (1 Reply)
Discussion started by: scriptfriend
1 Replies

6. Shell Programming and Scripting

find the line starting with a pattern and save a part in variable

Hi i have a file which has mutiple line in it. inside that i have a pattern similar to this /abc/def/hij i want to fine the pattern starting with "/" and get the first word in between the the symbols "/" i.e. "abc" in this case into a variable. thanks in advance (13 Replies)
Discussion started by: kichu
13 Replies

7. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

8. Shell Programming and Scripting

Reading text file, comparing a value in a line, and placing only part of the line in a variable?

I need some help. I would like to read in a text file. Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01. Is this possible? any help is appreciated. (2 Replies)
Discussion started by: xChristopher
2 Replies

9. Shell Programming and Scripting

Extract a part of variable/line content in a file

I have a variable and assigned the following values ***XYZ_201519_20150929140642_20150929140644_211_0_0_211 I need to read this variable from backward and stop read when I get first underscore (_) In this scenario I should get 211 Thanks Kris (3 Replies)
Discussion started by: mkris
3 Replies

10. Shell Programming and Scripting

How to remove part of the line from start of the line?

Hello, I am java command from a shell script which will generate the below output on the command prompt signature Base64 :... (10 Replies)
Discussion started by: chetanojha
10 Replies
HOBBITGRAPH.CFG(5)						File Formats Manual						HOBBITGRAPH.CFG(5)

NAME
hobbitgraph.cfg - Configuration of the hobbitgraph CGI SYNOPSIS
$BBHOME/etc/hobbitgraph.cfg DESCRIPTION
hobbitgraph.cgi(1) uses the configuration file $BBHOME/etc/hobbitgraph.cfg to build graphs from the RRD files collected by Xymon. FILE FORMAT
Each definition of a graph type begins with a "[SERVICE]" indicator, this is the name passed as the "service" parameter to hobbit- graph.cgi(1). If the service name passed to hobbitgraph.cgi is not found, it will attempt to match the service name to a graph via the TEST2RRD environment variable. So calling hobbitgraph.cgi with "service=cpu" or "service=la" will end up producing the same graph. A graph definition needs to have a TITLE and a YAXIS setting. These are texts shown as the title of the graph, and the YAXIS heading respectively. (The X-axis is always time-based). If a fixed set of RRD files are used for the graph, you just write those in the RRDtool definitions. Note that Xymon keeps all RRD files for a host in a separate directory per host, so you need not worry about the hostname being part of the RRD filename. For graphs that use multiple RRD files as input, you specify a filename pattern in the FNPATTERN statement, and optionally a pattern of files to exclude from the graph with EXFNPATTERN (see "[tcp]" for an example). When FNPATTERN is used, you can use "@RRDFN@" in the RRD- tool definitions to pick up each filename. "@RRDIDX@" is an index (starting at 0) for each file in the set. "@RRDPARAM@" contains the first word extracted from the pattern of files (see e.g. "[memory]" how this is used). "@COLOR@" picks a new color for each graph automatically. The remainder of the lines in each definition are passed directly to the RRDtool rrd_graph() routine. The following is an example of how the "la" (cpu) graph is defined. This is a simple definition that uses a single RRD-file, la.rrd: [la] TITLE CPU Load YAXIS Load DEF:avg=la.rrd:la:AVERAGE CDEF:la=avg,100,/ AREA:la#00CC00:CPU Load Average GPRINT:la:LAST: %5.1lf (cur) GPRINT:la:MAX: %5.1lf (max) GPRINT:la:MIN: %5.1lf (min) GPRINT:la:AVERAGE: %5.1lf (avg) Here is an example of a graph that uses multiple RRD-files, determined automatically at run-time via the FNPATTERN setting. Note how it uses the @RRDIDX@ to define a unique RRD parameter per input-file, and the @COLOR@ and @RRDPARAM@ items to pick unique colors and a match- ing text for the graph legend: [disk] FNPATTERN disk(.*).rrd TITLE Disk Utilization YAXIS % Full DEF:p@RRDIDX@=@RRDFN@:pct:AVERAGE LINE2:p@RRDIDX@#@COLOR@:@RRDPARAM@ -u 100 -l 0 GPRINT:p@RRDIDX@:LAST: %5.1lf (cur) GPRINT:p@RRDIDX@:MAX: %5.1lf (max) GPRINT:p@RRDIDX@:MIN: %5.1lf (min) GPRINT:p@RRDIDX@:AVERAGE: %5.1lf (avg) ADVANCED GRAPH TITLES
Normally the title of a graph is a static text defined in the hobbitgraph.cfg file. However, there may be situations where you want to use different titles for the same type of graph, e.g. if you are incorporating RRD files from MRTG into Xymon. In that case you can setup the TITLE definition so that it runs a custom script to determine the graph title. Like this: TITLE exec:/usr/local/bin/graphitle The /usr/local/bin/graphtitle command is then called with the hostname, the graphtype, the period string, and all of the RRD files used as parameters. The script must generate one line of output, which is then used as the title of the graph. ENVIRONMENT
TEST2RRD Maps service names to graph definitions. NOTES
Most of the RRD graph definitions shipped with Xymon have been ported from the definitions in the larrd-grapher.cgi CGI from LARRD 0.43c. SEE ALSO
hobbitserver.cfg(5), rrdtool(1), rrdgraph(1) Xymon Version 4.2.3: 4 Feb 2009 HOBBITGRAPH.CFG(5)
All times are GMT -4. The time now is 05:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy