Sponsored Content
Top Forums Shell Programming and Scripting Set lines of in a file to seperate vars Post 302279783 by lochraven on Friday 23rd of January 2009 05:49:14 PM
Old 01-23-2009
Set lines of in a file to seperate vars

In a bash script, I'm looking for a way to set each matching line of a file into its own variable, or variable array.

As an example, i have a crontab file with several entries:

00 23 * * * /usr/local/bin/msqlupdate -all
00 11 * * * /usr/local/bin/msqlupdate -inc
00 03 * * * /usr/local/bin/msqlupdate -inc
00 18 * * * /usr/local/bin/msqlupdate -inc

So I'm trying to grab each line, put it into a variable that can be modified.
i.e. var[1] = line 1
var[2] = line 2 etc...

I think the '*' are throwing off everything I'm trying.

Thanks for any assistance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Keeping vars set in while loop with redirection

Under IRIX 6.5, the Bourne shell is named /bin/bsh. I need to redirect output into a file reading loop, and retain values set within the loop based on processing that goes on within the loop for later processing. This code #!/bin/bsh k=1 cat file | while read k ; do echo "$k" done... (2 Replies)
Discussion started by: criglerj
2 Replies

2. Shell Programming and Scripting

Setting local vars from a header rec in another file?

Hey guys, We are going to be receiving files containing header information. This will be 1 line of code in each file containing the following format: 20050719hhmmsssfgr00310000537000000000000000 My question is...How can I pull parts of the header info and set it to vars in my shell. I... (4 Replies)
Discussion started by: ecupirate1998
4 Replies

3. Shell Programming and Scripting

how to awk a data from seperate lines

Hi guys, i have a problem which im hoping you will be able to help me with. I have follwing output :- ------------------------------------------------------------------------------- NSTEP = 407000 TIME(PS) = 43059.000 TEMP(K) = 288.46 PRESS = 0.0 Etot = -2077.4322 ... (2 Replies)
Discussion started by: Mish_99
2 Replies

4. Shell Programming and Scripting

shellscript to find a line in between a particular set of lines of a text file

i have a file a.txt and following is only one portion. I want to search <branch value="/dev36/AREA/" include="yes"></branch> present in between <template_file name="Approve External" path="core/approve/bin" and </template_file> where the no of lines containing "<branch value= " is increasing ... (2 Replies)
Discussion started by: millan
2 Replies

5. Shell Programming and Scripting

split a sentence and seperate into two lines

Hi, I have a string as str="route net,-hopcount,1,255.255.255.0,10.230.20.111,10.230.20.234 Route True route net,-hopcount,0,-netmask,255.255.248.0,0,10.230.23.254 Route True" I need to split this string into two lines as route net,-hopcount,1,255.255.255.0,10.230.20.111,10.230.20.234... (4 Replies)
Discussion started by: chaitanyapn
4 Replies

6. UNIX for Advanced & Expert Users

Set vars (by reference) in function

Hello everyone, I am curious to find a possible way of doing something like this in ksh: call a function and have that function set the value of the variable that the function knows by the name of $1.... example: #! /bin/ksh set_var(){ case $1 in var1) this is where I would like to... (7 Replies)
Discussion started by: gio001
7 Replies

7. Shell Programming and Scripting

Set/Export Env Vars from with Shell Script With Input Variable

I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example: $ mgenv.sh prod This would set environment variables for prod $ mgenv.sh test This would set environment variables... (1 Reply)
Discussion started by: brtaylor73
1 Replies

8. UNIX for Dummies Questions & Answers

How to seperate two lines that are joined?

i have something like this abc 123 3234 1234 * qqoiki * abc 4533 34 1234 * lloiki * i want to make it two lines i,e.,abc 123 3234 1234 * qqoiki * abc 4533 34 1234 * lloiki * how to do that ? (13 Replies)
Discussion started by: anurupa777
13 Replies

9. Shell Programming and Scripting

Delete a set of lines from a file

Hi All, Am very new for this Shell scripting. Could anyone pls let me know how to delete a set of lines from a (.DAT) file using ksh script. for example from line 3 to line 7. The size of the target file is huge:( ---------- Post updated at 11:01 PM ---------- Previous update was at 11:00 PM... (5 Replies)
Discussion started by: kasthu12
5 Replies

10. UNIX for Dummies Questions & Answers

Removing a set of Duplicate lines from a file

Hi, How do i remove a set of duplicate lines from a file. My file contains the lines: abc def ghi abc def ghi jkl mno pqr jkl mno (1 Reply)
Discussion started by: raosr020
1 Replies
Alien::Package::Rpm(3pm)				User Contributed Perl Documentation				  Alien::Package::Rpm(3pm)

NAME
Alien::Package::Rpm - an object that represents a rpm package DESCRIPTION
This is an object class that represents a rpm package. It is derived from Alien::Package. FIELDS
prefixes Relocatable rpm packages have a prefixes field. METHODS
checkfile Detect rpm files by their extention. install Install a rpm. If RPMINSTALLOPT is set in the environement, the options in it are passed to rpm on its command line. scan Implement the scan method to read a rpm file. unpack Implement the unpack method to unpack a rpm file. This is a little nasty because it has to handle relocatable rpms and has to do a bit of permissions fixing as well. prep Prepare for package building by generating the spec file. cleantree Delete the spec file. build Build a rpm. If RPMBUILDOPT is set in the environement, the options in it are passed to rpm on its command line. An optional parameter, if passed, can be used to specify the program to use to build the rpm. It defaults to rpmbuild. version Set/get version. When retreiving the version, remove any dashes in it. postinst postrm preinst prerm Set/get script fields. When retrieving a value, we have to do some truely sick mangling. Since debian/slackware scripts can be anything -- perl programs or binary files -- and rpm is limited to only shell scripts, we need to encode the files and add a scrap of shell script to make it unextract and run on the fly. When setting a value, we do some mangling too. Rpm maintainer scripts are typically shell scripts, but often lack the leading shebang line. This can confuse dpkg, so add the shebang if it looks like there is no shebang magic already in place. Additionally, it's not uncommon for rpm maintainer scripts to contain bashisms, which can be triggered when they are ran on systems where /bin/sh is not bash. To work around this, the shebang line of the scripts is changed to use bash. Also, if the rpm is relocatable, the script could refer to RPM_INSTALL_PREFIX, which is set by rpm at run time. Deal with this by adding code to the script to set RPM_INSTALL_PREFIX. arch Set/get arch field. When the arch field is set, some sanitizing is done first to convert it to the debian format used internally. When it's retreived it's converted back to rpm form from the internal form. AUTHOR
Joey Hess <joey@kitenet.net> perl v5.12.3 2011-06-11 Alien::Package::Rpm(3pm)
All times are GMT -4. The time now is 04:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy