The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
update a file with values from other file in shell bash teodora Shell Programming and Scripting 1 07-03-2008 08:39 AM
Converting Binary decimal coded values to Ascii Values gaur.deepti UNIX for Advanced & Expert Users 3 04-02-2008 09:33 AM
Extract values from log file wdympcf Shell Programming and Scripting 5 08-10-2007 12:52 AM
taking snapshot of a file bryan UNIX for Dummies Questions & Answers 1 09-09-2005 07:42 AM
Perl: taking text from a .txt file perleo Shell Programming and Scripting 2 06-19-2003 07:23 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 4 Weeks Ago
jin jin is offline
Banned
 

Join Date: Aug 2008
Posts: 2
Question Please help me in taking the values from a file

i have a script, whcih takes values from a file and assign it to one variable. this text value contains name of few object. value contains line by lie. i.e. one after another.

when i am assaign the value of this text file to a variable, it accept the value as one liner instead of one by one. pls help me in this.


#!/bin/bash
exclude="`cat /tmp/excludejobs`"
echo $exclude > /tmp/testexclude
find /home/bosuser/Production/jil/* | xargs grep /home/bosuser|cut -d "." -f1|cut -d "/" -f6|uniq > /tmp/includejob
job="`cat /tmp/includejob`"
echo $job > /tmp/testinclude

for i in $job
do

if [ $i != $exclude ]
then
anjil -sd $job > /tmp/document
cat /tmp/documnet | grep 'Team Mail Alias' > /tmp/rawmail
cat /tmp/rawmail | cut -d ":" -f2 > /tmp/mailalias
/usr/ucb/mail -s "notification" xx@yyyyy.com
fi


here the value takes as one liner instead of one by one.

in csh sheel we have "foraech" command but in bash how can i fullfill this

Last edited by DukeNuke2; 4 Weeks Ago at 10:23 PM. Reason: changed email
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 4 Weeks Ago
ynilesh's Avatar
Registered User
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 162
Just replace follwing line in your program and it should work.

Code:
echo "$exclude" > /tmp/testexclude
echo "$job" > /tmp/testinclude
One suggestion, Use less number of files, pipes and shell commands in script. This will help to improve performance of your script.

If this also doesnt work please let me know
- nilesh
Reply With Quote
  #3 (permalink)  
Old 3 Weeks Ago
jin jin is offline
Banned
 

Join Date: Aug 2008
Posts: 2
Question how to take a value which comes above the search string

tht has been resolved.. any way thaks for your reply. i have another query.

I have a file , which having the following out put

insert_job: PS_PositivePayBox job_type: b
insert_job: PS_PositivePay_MOBox job_type: b
insert_job: PS_PositivePay_MO_norun job_type: c
owner: bosuser

insert_job: PS_PositivePay_MO_Watch job_type: f
insert_job: PS_Wait_MO job_type: c
owner: bosuser

insert_job: PS_Fetch_MO job_type: c
insert_job: PS_Notify_MO job_type: c
owner: bosuser

insert_job: PS_PositivePay_BWBox job_type: b
insert_job: PS_PositivePay_BW_norun job_type: c
owner: bosuser
insert_job: PS_PositivePay_BW_Watch job_type: f

I need to find all the insert_job line, which comes above owner: bosuser

For eg.

insert_job: PS_PositivePay_BW_norun job_type: c
owner: bosuser

I need the , “ insert_job: PS_PositivePay_BW_norun job_type: c”

What can be the command
Reply With Quote
  #4 (permalink)  
Old 3 Weeks Ago
ynilesh's Avatar
Registered User
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 162
Use,
Code:
grep -B 1 "owner: bosuser" {filename}
Output will same like what you want,
Quote:
insert_job: PS_PositivePay_MO_norun job_type: c
owner: bosuser
--
insert_job: PS_Wait_MO job_type: c
owner: bosuser
--
insert_job: PS_Notify_MO job_type: c
owner: bosuser
--
insert_job: PS_PositivePay_BW_norun job_type: c
owner: bosuser
- nilesh
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0