1832255 Members
2543 Online
110041 Solutions
New Discussion

shell script help

 
kholikt
Super Advisor

shell script help

I am currently writing some script to use omniback to initialize a tape. After initialize it will automatcially add the media id to the backup specification pre-allocation list.

I need to search through this backup specificaton file inside /etc/opt/omni/datalists.

I need to search for prealloc keyword inside the file and append the new media id to this section and save the file.



DATALIST "test_backup"
DYNAMIC 1 5
DEFAULTS
{
FILESYSTEM
{
-no_storedrim

} -protect none
RAWDISK
{

}
}

DEVICE "abc_lto"
{
-pool "ABC"
-prealloc
"0a140507:3f6ab3f2:0e2d:0001"
----> I need to append the new media_id here..
}

HOST "abc.esc" abc.esc
{
-trees
"\"
-exclude
"C:\temp"
"G:"
"H:"
}
abc
1 REPLY 1
Rodney Hills
Honored Contributor

Re: shell script help

You could use "awk" (or perl) to scan the file look for the proper place and insert. Here is an example with "awk"-

awk -vnewid="$newid" '/^-prealloc/{gotpre=1};/^}/{if (gotpre) print newid ; gotpre=0};{print $0}' test

Assuming shell variable "newid" has the data line to add. This will scan for "-prealloc", then look for the first "}" and insert the extra line.

HTH

-- Rod Hills
There be dragons...