SED and Read Help Needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED and Read Help Needed
# 1  
Old 09-25-2008
Question SED and Read Help Needed

Not sure why my sed script is not working..need extra eyes..Any help would be aprreciated.

I want to add this line into the 1rst line of the $EJECT FILE
sed '/">>>>>>>>>>>>> TAPES TO BE EJECTED /a\<<<<<<<<<<<<<<<<<"'> $EJECT

This is the error message I get:
+ sed /">>>>>>>>>>>>> TAPES TO BE EJECTED /a\<<<<<<<<<<<<<<<<<"
sed: command garbled: /">>>>>>>>>>>>> TAPES TO BE EJECTED /a\<<<<<<<<<<<<<<<<<"
+ cat /export/home/legato/tapemgr/rpts/offsite/unallocate_IP_tapes.092508


After the read function, it does not return back to main menu:
Read Function problem:



Once I enter the date and it processes, I would like it to go back to the tapemgr_main_menu.. but it does do that..it prompts again for the read input date.

Tapes_Offsite_Menu()
{
while true
echo "Please enter date as xx/xx/xx "; read input
do
total=`mminfo -r volume -q "location=SL8500,savetime<$input,volretent>01/01/09" |wc -l`

echo "$dat BUR-COSD Offsite(CDC) SL8500/MOD2 Tape Report" > $OFFSITE
echo "TapeOps .. Please send these tapes to OFFSITE" > $OFFSITE
mminfo -r volume,%used,volretent,pool,location -q "pool=NDMPool,location=SL8500,savetime<$input,volretent>01/01/09" >>$OFFSITE >&1
echo "Total OFFSITE cosd TAPES..$total" >> $OFFSITE ; cat $OFFSITE
echo "Did you want to unallocate these tapes from Networker? '(y/n)'";
read unallocate;echo $unallocate
case $unallocate in
n|N) echo " --TAPES NOT EJECTED OR UNALLOCATED .. REPORT LIST ONLY";RPT_ONLY="y";;
y|Y) mminfo -q "pool=NDMPool,location=SL8500,savetime<$input,volretent>01/01/09" -r volume|tee $EJECT_TAPES
echo "Tapes will be unallocated--UNALLOCATE_TAPES"
cat $EJECT_TAPES;
UNALLOCATE_TAPES;;
esac
unallocate=" "
EMAIL_NOTIFICATION
tapemgr_Main_Menu
done
}
# 2  
Old 09-25-2008
Does sed understand that syntax at the command line? Are you sure the script executes the same version of sed? There are different sed versions and not all of them accept the a\ string on the same line. Perhaps this would work better:

Code:
sed '/">>>>>>>>>>>>> TAPES TO BE EJECTED /a\
<<<<<<<<<<<<<<<<<"'

I'm a bit surprised by the double quotes but perhaps they are supposed to be that way?

You have the "do" from the "while" after the "echo" but it should apparently be before. The while command can accept multiple commands before the do (that's why the special token "do" is required to show where the commands for the condition ends) but I don't think you want that here.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed Help Needed

I want to search texts between first occurence of the matching pattern and replace it with some other text.pls advice what can be done. I searched alot, i could not find anything relevant. Ex my input is as follows: red yellow grey white blue red pink violet white I want to search... (9 Replies)
Discussion started by: sangitajc
9 Replies

2. Shell Programming and Scripting

Needed shell script to read txt file and do some modification

Hi ...programmers... I need a shell script to perform some specific task.. my txt file looks like this netcdf new { dimensions: XAX1_11 = 11 ; variables: double XAX1_11(XAX1_11) ; XAX1_11:point_spacing = "even" ; XAX1_11:axis = "X" ; float DEPTH(XAX1_11) ;... (19 Replies)
Discussion started by: Akshay Hegde
19 Replies

3. Shell Programming and Scripting

help needed with SED

Hello! I have a "problem" with sed... In a log, I'm wondering how to have the name of the application when "INCIDENT" is in the file... The name of the application is before "INCIDENT". For this example, The result should be "SPVP0005" thanks for your help! (7 Replies)
Discussion started by: Castelior
7 Replies

4. Shell Programming and Scripting

Shell Script Needed to Read a text from a list files

Hi, Below is my issue which I desperately need and I want a shell script which can do this job. I need this script as I m planning to put this for a system health check. Please assist me. 1. There are 10 log files in a particular location. 2. open each log file. Goto to the end of the... (4 Replies)
Discussion started by: kashriram
4 Replies

5. Shell Programming and Scripting

URGENT: Script/Function needed to read text property files in block wise

Hi, Iam in a need for a script/function in KSH where I want to read a text file (property file) in block by block. Here is the example: Heading Name Descripton Block Block1 Value1 Description Property Name Value Property Name Value Property Name Value Property Name Value Property Name... (7 Replies)
Discussion started by: ysreenivas
7 Replies

6. Shell Programming and Scripting

Help needed on SED

Hi, I would like to process one file which looks like this : 09-04-16-17:11:53 -> count 1 NAME CHAN QID NMSGS NBYTES MAXBYTES P/T W_DEALNUM 105 123508770 1 10 14 P W_APPSTAT 106 123508771 1 12 35 P... (8 Replies)
Discussion started by: vive123
8 Replies

7. UNIX for Dummies Questions & Answers

sed help needed

Hi there, I have a folder with many files where the first line has almost the same pattern in all the files and I want to replace this one with another which is going to be the same in all the files. So the first line of all the files begins like UNB+IATA:1+CHUAGT87HUUPSS/BUD01:PIMA and... (4 Replies)
Discussion started by: sickboy
4 Replies

8. Shell Programming and Scripting

help with sed needed

Hi, I have a file in a form of jkkhjjk1:!:jkhdjkhjkh2:!:kljkljkljklj3:!:kljsdj4 kljlkfljf5:!:kjljljlj6:!:jhjkhjkh7 I am trying to use sed command such that everytime it find ":!:" it will removes it and print remaining of the line on the new line Output that I need will look like following... (8 Replies)
Discussion started by: arushunter
8 Replies

9. Shell Programming and Scripting

Help Needed -sed

Hi All, i have one file and in that i have to read each line and do some replacement. its is not fixed the number or column always be same it can be less also exm a;b;c;d;e;f (line) i have to do something like In the line If c is present then go to end of line and append ';date' else... (9 Replies)
Discussion started by: ravi.sadani19
9 Replies

10. UNIX for Dummies Questions & Answers

help Needed for READ command.....

Hi UNIX BONDS, My requirement is that i want to use READ as while read a x y z do some logic done < dummy_file.txt But the requirement is that the number of columns in the file dummy_file.txt is not fixed. So "while read a x y z" may work fine if there are four columns, but how do... (2 Replies)
Discussion started by: rahul26
2 Replies
Login or Register to Ask a Question