As glad as we are to help, please consider reading man pages, e.g. man bash/ksh/your shell, to help yourself; those are immense sources of knowledge...!
1) man bash:
Quote:
test expr
If the first argument is ! , the result is the negation of ...
so: if ! means if NOT
2) man regex:
Quote:
A (modern) RE is one(!) or more nonempty(!) branches, separated by '|'
so (^|:)$1($|:) means $1 enclosed in : or at the begin-of-line ( ^ ) or at the end-of-line ( $ )...
In this example function below, I cannot figure out what certain parts mean.
what is "if !"?
What is
and
?
Actually, think it more like this:
The highlighted parenthesis represents how you should see that line of code. They are not intended to be included. echo $PATH output becomes the input of egrep, which is asked to find a pattern in that output of echo.
It is looking for the following pattern:
By placing a ! in front of the whole expression, it turns it into if not found
Look how pathmunge is used below, as an example:
In English terms:
If /usr/X11R6/bin does not exist append to the path (at the end). That's the after argument.
Attention, if ! ( ... ) would run ... in a sub-shell. This is extra fork-overhead, and can have some other impact, like a ((var+=1)) will not copy back to the main shell.
Actually this patchmunge() function is in RH/CentOS 5 /etc/profile. And is risky, at least one must quote
And also needs an external program /bin/egrep.
It is improved in RH/CentOS 6:
The functionality of pathmunge is:
it prepends the 1st argument to the PATH (if not yet exists), unless the 2nd argument is "after" where it appends the 1st argument to the PATH (if not yet exists).
Hi,
I am new to shell scripting and i need to write a automation script to execute sql files. I need to check the table if it is there in system tables and need to write a function to call the .sql files.
For ex. I have a.sql,b.sql,c.sql files, where the sql file contains DELETE and INSERT... (1 Reply)
Hi Guys,
i'm new to scripting, please help me to write the script.
Purpose: To write a simple addition program and to mail the output result.
Script:
#!/bin/bash
echo "entr numbers";
read n1;
read n2;
answer=$(($n1+$n2));
echo $answer > mail -s "output" karthic324n@gmail.com;
... (4 Replies)
Hi I have a function :
Make_Report()
{
trx_report=`sqlplus -s $conn_str << @@
set echo off;
set pages 0;
set feedback off;
set verify off;
select srv_trx_s_no,... (1 Reply)
Hi All,
I am calling a series of shell scripts via CRON so everything is running as root. However, in my error log file I am seeing the following errors. Please can anyone offer any advise as to the possible causes and solution to prevent the errors from appearing.
The Error 1227 seems to... (2 Replies)
Hello, I have made a Linux Shell Script that downloads 6 files from the Internet and then deletes them. Now i want to use the function "/usr/bin/time" and "bc" to calculate how long the avergate run time for the shell script is. I therefore need to do it 100 times. My shell script code is below:
... (6 Replies)
Hi, i was reading through a sample coding and came across this function, can anyone pls help to interpret the code for me. Thank alot
find_lines()
{
res=-1
if ; then
grep -i "$@" $FILENAME
res=$?
fi
return $res
} (2 Replies)
Greetings to all.I am new to the forum as well as to UNIX as well.I have a jsp file which has the following
selectedStartMonth = request.getParameter( "startMonth" );
selectedStartDay = request.getParameter( "startDay" );
selectedStartYear = request.getParameter( "startYear" );... (3 Replies)
Hello everybody,
I trying to convert a text inside my file that looks something like this:
into hyperlink so that the user can click onto it.....
I tried this but doesn't work
cat mylist9.html |sed -e '<a href="' >mylist13.html
Thanks (13 Replies)
Like class loader in java, can we make a function loader in shell script, for this can someone throw some light on how internally bash runs a shell script , what happenes in runtime ...
thanks in advance.. (1 Reply)
I am struggling with the following sample code:
array1=(a b c d)
array2=(* * * *)
print ${array1}
print ${array2}
It returns 'c' and the name of a file in the directory I'm in.
I can't for the life of me work out how to prevent the shell interpreting the '*' and just get it to return... (2 Replies)