Sponsored Content
Full Discussion: explain the code
Top Forums UNIX for Advanced & Expert Users explain the code Post 302288862 by justsam on Wednesday 18th of February 2009 07:18:44 AM
Old 02-18-2009
. ${0%/*}/wrkenv.sh
gets the directory path (as is executed) of the running script and sources the script wrkenv.sh present in the above reslut directory.
If user is running a script as /home/justsam/test.sh , then the first line of the code fetches the directory (/home/justsam in this case and sources the wrkenv.sh script

jobName_sh=${0##*/}
This is meant to remove all characters before the last “/ “from the path entered to invoke the script, leaving only the name of the script.

## matches the longest match from start of the string, and looks for the last occurrence of “/” from beginning, if only # was used it would match the shortest match from start of the string, looking for the first occurrence of “/” from beginning.



jobName=${jobName_sh%.*}
This is meant to remove '.' and all the characters after the '.'
Ex: If jobName_sh in test.sh, then .sh is removed and gives the name of the file without the extension.
justsam
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

could someone explain this code

hey peeps could someone explain what this part of the code means: 'if echo $* | grep -q' $i '|| thanks tHe_nEw_GuY (2 Replies)
Discussion started by: the_new_guy
2 Replies

2. Shell Programming and Scripting

Can any one explain what this code will do

ccc_con,CCC_CON,0 Above is the input for this code #!/usr/bin/bash my_path=`dirname $0` T_table=$1 S_table=$2 P_table=$3 #Star new code while read ${my_path}/arch_table_list.txt { awk -F "," '{print $1}' ${my_path}/arch_table_list.txt ${S_table} awk -F "," '{print... (1 Reply)
Discussion started by: scorp_rahul23
1 Replies

3. Shell Programming and Scripting

can any one explain the meaning of the below code ?

while getopts :g:l:h: KEY $* do case $KEY in g) NAME=$OPTARG ;; l) LAB=$OPTARG ;; h) HD=$OPTARG ;; *) echo "Illegal option: $OPTARG" echo "$usage" exitStatus=1 exitGrace esac done (2 Replies)
Discussion started by: santosh1234
2 Replies

4. Programming

Explain a block of code:

Hi, I have this block in a code and I need to know it's meaning: bool selectEvents = config.get("selectEvents",false); if (selectEvents) { ifstream in("events"); while (in) { int run, evt; in >> run >> evt; if (in.eof()) break; ... (5 Replies)
Discussion started by: eager2no
5 Replies

5. Shell Programming and Scripting

Explain SED code

Hi, Can anyone pls explain me the below SED code in detail. sed -e :a -e '$!N;s/\n//;ta' -e P -e D When this code is executed with a file(has 1lac records), it is taking very long time to process. So I wanted to modify this SED code with equivalant AWK code. Thanks, Sri (1 Reply)
Discussion started by: srilaxmi
1 Replies

6. Shell Programming and Scripting

Can someone explain the 2 lines of code?

I have something like in the script. Can anyone explain what does the sort command does and followed by the sed sort -r -k3.7,3 -k3.1,3 -k3.4,3 -t: $dir"abc_"$x"_parsed" | sed -e 's/\(\)\(\{3\}\)/\1,\2/2' -e 's/\/2,00/\/200/' The file abc_"$x"_parsed contains something like below ... (7 Replies)
Discussion started by: Muthuraj K
7 Replies

7. Shell Programming and Scripting

Please explain what this code is doing

Hi, Pls explain me what the below code is doing. specially meaning if -a while calling test function- case $1 in 1) beg_dt=01; end_dt=07 ;; 2) beg_dt=08; end_dt=14 ;; 3) beg_dt=15; end_dt=21 ;; 4) beg_dt=22; end_dt=28 ;; 5) beg_dt=29; end_dt=31 ;; esac test \( `date +%w` -eq $2 -a... (3 Replies)
Discussion started by: sendtoshailesh
3 Replies

8. Shell Programming and Scripting

Explain this shell script code.

Hi i am new to shell script can any one please explain me the code below which is written for execution of python scripts which are located in same folder. please explain the code line by line ls *.py > xx while do read myline || break python $myline done<xx Thanks Mukthyar.... (1 Reply)
Discussion started by: mukthar1255
1 Replies

9. Shell Programming and Scripting

Please explain what this Awk code is doing

Hi Guys, Please help me, I am new to programming and I don’t understand what some parts of this code are doing. I have comments on the parts I know, please help if my understanding of the code is not correct and also help with parts with questions. awk ' { gsub( ">",... (1 Reply)
Discussion started by: James_Owen
1 Replies

10. Shell Programming and Scripting

can you explain this sed code?

can anyone please explain this code? sed ':a;N;$!ba;s/]\n//g' file it replaces lines ending with "]" and concatenates with the next line so that line1] line2 becomes line1line2 i don't understand this part: :a;N;$!ba; I have noted that I can replace "a" with any letter: ... (1 Reply)
Discussion started by: locoroco
1 Replies
HIGHLIGHT_FILE(3)							 1							 HIGHLIGHT_FILE(3)

highlight_file - Syntax highlighting of a file

SYNOPSIS
mixed highlight_file (string $filename, [bool $return = false]) DESCRIPTION
Prints out or returns a syntax highlighted version of the code contained in $filename using the colors defined in the built-in syntax highlighter for PHP. Many servers are configured to automatically highlight files with a phps extension. For example, example.phps when viewed will show the syntax highlighted source of the file. To enable this, add this line to the httpd.conf: AddType application/x-httpd-php-source .phps PARAMETERS
o $filename - Path to the PHP file to be highlighted. o $return - Set this parameter to TRUE to make this function return the highlighted code. RETURN VALUES
If $return is set to TRUE, returns the highlighted code as a string instead of printing it out. Otherwise, it will return TRUE on success, FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 4.2.1 | | | | | | | This function is now also affected by safe_mode | | | and open_basedir. | | | | +--------+---------------------------------------------------+ NOTES
Caution Care should be taken when using the highlight_file(3) function to make sure that you do not inadvertently reveal sensitive informa- tion such as passwords or any other type of information that might create a potential security risk. Note When the $return parameter is used, this function uses internal output buffering so it cannot be used inside an ob_start(3) callback function. SEE ALSO
highlight_string(3), Highlighting INI directives. PHP Documentation Group HIGHLIGHT_FILE(3)
All times are GMT -4. The time now is 03:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy