Sponsored Content
Full Discussion: Multiple varibles in file
Top Forums Shell Programming and Scripting Multiple varibles in file Post 302423959 by numele on Sunday 23rd of May 2010 09:48:34 PM
Old 05-23-2010
Multiple varibles in file

Working on a way to speed up my script output. I have a multiline file that I pull each line as a variable and post it on a webpage. It needs some help as it works but slow. I think I have too many cat, grep and sed going on but don't know what would work better.
Code:
#!/bin/sh
FILE=/export/htdocs/request/$REQUEST
DATE=`cat $FILE | grep "DATE=" | sed -n 's/.*=//p'`
NAME=`cat $FILE | grep "NAME=" | sed -n 's/.*=//p'`
EMAIL=`cat $FILE | grep "EMAIL=" | sed -n 's/.*=//p'`
PHONE=`cat $FILE | grep "PHONE=" | sed -n 's/.*=//p'`
UID=`cat $FILE | grep "UID=" | sed -n 's/.*=//p'`
COMPANY=`cat $FILE | grep "COMPANY=" | sed -n 's/.*=//p'`
OC=`cat $FILE | grep "OC=" | sed -n 's/.*=//p'`
PRIORITY=`cat $FILE | grep "PRIORITY=" | sed -n 's/.*=//p'`
EXPLAIN=`cat $FILE | grep "EXPLAIN=" | sed -n 's/.*=//p'`
JUSTIFICATION=`cat $FILE | grep "JUSTIFICATION=" | sed -n 's/.*=//p'`
COMMENTS=`cat $FILE | grep "COMMENTS=" | sed -n 's/.*=//p'`
REGION=`cat $FILE | grep "REGION=" | sed -n 's/.*=//p'`
ADD_DELETE=`cat $FILE | grep "ADD_DELETE=" | sed -n 's/.*=//p'`
FILTER=`cat $FILE | grep "FILTER=" | sed -n 's/.*=//p'`
TYPE=`cat $FILE | grep "TYPE=" | sed -n 's/.*=//p'`
SOURCE_IP=`cat $FILE | grep "SOURCE_IP=" | sed -n 's/.*=//p'`
PORT=`cat $FILE | grep "PORT=" | sed -n 's/.*=//p'`
STATUS=`cat $FILE | grep "STATUS=" | sed -n 's/.*=//p'`

Here is a sample file it is pulling from
Code:
NAME=John Smith
EMAIL=jsmith@testmail.com
PHONE=212-555-1212
UID=gg1234
COMPANY=OTHER
OC=ABC Company
REGION=All
ADD_DELETE=Add
FILTER=Mail
SERVICE_TYPE=TCP
SOURCE_IP=10.1.1.1
PORT=25
REGION=All
ADD_DELETE=Delete
FILTER=Router Access
SERVICE_TYPE=TCP
SOURCE_IP=192.168.1.0/24
PORT=23
PRIORITY=Normal
EXPLAIN=This is an example explanation
JUSTIFICATION=Business justification description
COMMENTS=No comments
DATE=05/23/2010
STATUS=Pending

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

environmental varibles

flavor -- AIX 4.2.1 I am putting together some HTML pages, some of which contain forms. The problem pops up when I attempt to pass variables (from the forms) from one HTML page to a cgi-like page created using ksh. I have used the $1 - $9 vars, but they do not work with the passing. With... (1 Reply)
Discussion started by: Xiix
1 Replies

2. Shell Programming and Scripting

Dynamic Varibles problem

All, Any chance someone could help me with this.... The script is reading from a file and for every line of input to the loop I am trying to assign a new varible. When i run the script I get the below errors. I have come to a bit of a dead end so any pointers/help would be very much... (1 Reply)
Discussion started by: oconnon2
1 Replies

3. UNIX for Dummies Questions & Answers

different way to echo varibles...help

Given the following loop: foreach id (DB4 GH4 CD4) and the previously defined variables: DB4sf DB4sfk DB4pp GH4sf GH4sfk GH4pp CD4sf CD4sfk CD4pp how do i echo all of these variables using a one line command in the for loop. If it was a script, and assuming the previously mentioned... (8 Replies)
Discussion started by: wxornot
8 Replies

4. UNIX for Dummies Questions & Answers

How to create ENV varibles

Hi, I want create env variable for "/ramakrsihna/scripts" help me on this. (1 Reply)
Discussion started by: koti_rama
1 Replies

5. Shell Programming and Scripting

split varibles and store fields into shell varible array

I need to split a long varible which is a whole line read from a file into fields and store them in an array, the fields are delimited by pipe and a field may contain white spaces. I tried the following concept test and it has problem with field 5 which contain a space, appearently so because... (3 Replies)
Discussion started by: gratus
3 Replies

6. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

7. Shell Programming and Scripting

Passing varibles as a string argument ?

For example test.sh: test="teststring" cmd=$1 $cmd For some reason I'm NOT seeing "teststring" when I type: ./test.sh "echo $test" Any ideas on how to get around this? I've tried commands like: ./test.sh "echo $($test)" ./test.sh "echo '$test'" And many variations to no... (6 Replies)
Discussion started by: secops
6 Replies

8. UNIX for Dummies Questions & Answers

Need Help Setting Path and Environment Varibles

Hello all, I have a Mac OS X (10.7), and I need to set environment variables and paths for some programs I will be running. I have followed instructions and searched the Web for where to do this, but I can't seem to find an answer. I have tried using the VIM editor to write them into my .login,... (2 Replies)
Discussion started by: Tyler_92
2 Replies

9. Shell Programming and Scripting

Grep and replace multiple strings in a file with multiple filenames in a file

Hi, I have a file containing list of strings like i: Pink Yellow Green and I have file having list of file names in a directory j : a b c d Where j contains of a ,b,c,d are as follows a: Pink (3 Replies)
Discussion started by: madabhg
3 Replies

10. Shell Programming and Scripting

Grep from multiple patterns multiple file multiple output

Hi, I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command. Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns. Xargs -I {} grep... (3 Replies)
Discussion started by: Diya123
3 Replies
smd-pull(1)						 Sync Mail Dir (smd) documentation					       smd-pull(1)

NAME
smd-pull - syncs the local mail dir letting the remote one untouched SYNOPSIS
smd-pull [-d|--dry-run] [-v|--verbose] [-s|--show-tags] [-t|--template-only] [-n|--no-delete] [endpoint] DESCRIPTION
smd-pull performs in the local maildir all the changes that were performed on remote one. No changes are made on the remote maildir. Use smd-push(1) for that. Refer to smd-config(5) for the configuration file format. OPTIONS
-v --verbose Verbose output -s --show-tags Machine readable output -d --dry-run Do not perform any action for real -n --no-delete Do not propagate deletions -t --template-only Just create a template configuration file if none endpoint Is the suffix for the name of the configuration file to use. If it is omitted, the configuration file ~/.smd/config.default is used. FILES
~/.smd/config.* ~/.smd/hooks/pre-pull.d/ ~/.smd/hooks/post-pull.d/ SEE ALSO
mddiff(1), smd-server(1), smd-client(1), smd-push(1), smd-loop(1), smd-config(5) AUTHOR
Enrico Tassi <gares@fettunta.org> 11 June 2012 smd-pull(1)
All times are GMT -4. The time now is 08:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy