Syntax:
zip <zip_file_name>.zip <files_to
zip>.txt
12. For Loop Syntax
Syntax
for <Variable> in
<Command><expression>
do
<Statement>
done
Example:
for variable in `grep -l "^TEST*.* "
<Directory_path>/*.*|cut -f 13 -d"/"`
do
<Statement>
Done
Above statement would search
for the test TEST in the directory path and the file name that is mentioned
after the 13th position of “/” (Changes based on the directory path description)
13. Searching a pattern in a file
Syntax:
grep -c '^L'
<directory_path>/<File_name>
Here it searches for the test “L” in the file
mentioned
14. Command to sort a file
Syntax:
sort -u <Directory_Path><File_name>
> <Directory_Path><Sort_file_Name>
Section 2
Now let us know some of the advance commands that
we use while scripting using UNIX Script. Let us assume that we have a
requirement of creating a HOST script and registering it in the Application as
a concurrent program and by invoking the Concurrent program that in turns
invokes our HOST script to perform the defined task.
Commands used while scripting using UNIX and
which is invoked by a concurrent program once it is registered in APPS as a
HOST script would be discussed.
Suppose we have created a Concurrent Program and
for instance our concurrent program are having parameters.
1. Command used to fetch all the concurrent parameters including system
defined parameters into a variable in SHELL SCRIPT
Syntax:
l_all=`echo $@`
Here l_all variable will have all the parameters
of the concurrent program
Based on our requirement if we need the
Request_ID of the CP and the User_Name who has submitted the Concurrent Program
(CP)
Syntax:
l_request_id=`echo $l_all | tr -s " "
" "|cut -f2 -d" "|cut -f2 -d"="`
l_user_name=`echo $l_all | tr -s " "
" "| cut -f5 -d" "| cut -f2 -d"="|sed -e
's/"/ /g'` Suryakanth Gunti UNIX GUIDE Page 4
Here l_request_id and
l_user_name would hold the value of the Concurrent program request id and the
username.
Apart from the System Parameters if we have also
defined our own custom parameters
Syntax:
l_param=`echo $l_all| cut -f9-300 -d' ' | sed
's/" "/"|"/g'`
Fetch all the Custom defined parameters of the CP
into a variable l_param
Now for instance we have defined say 4 parameters
Responsibility name, Out Directory Path, Archive Directory Path and Log
directory path. To fetch these parameters into a variable
Syntax
l_resp_name=`echo $l_param | cut -f1 -d"|"|tr
-d \"`
l_out_dir=`echo $l_param | cut -f2
-d"|"|tr -d \"`
l_archive_dir=`echo $l_param | cut -f3
-d"|"|tr -d \"`
No comments:
Post a Comment