CHECK="tftp nfs http"
for i in $CHECK ; do
RPMFILE=`rpm -qa $i`
echo $RPMFILE;
done
2)/etc/init.d/fucntion it has some default predefined function. like
success,failure we can use these function from there itself.
3)Shell Scripting File Proprieties.
-f | File |
-d | Directory |
-r | File name test for readable |
-w | File name test for writable |
-x | File name test for executable or not |
-s | File is not empty |
4)Declare the function and call the function.
Function_name()
{
statement ;
}
To call the function
function_name
5)Write the Data into the File.
#cat > File_name << EOF
data1
data2
EOF
6)How to Debug the Shell Scripting
#bash -x ./script.sh [ debugging the script file] Display all the command and arguments when they are executed.
#bash -v ./script.sh [ verbose mode ]
#bash -xv ./script.sh
7)Shell Scripting Logical And OR NOT
! | Logical Not |
-a | Logical And && |
-o | Logical Or || |
! tests for logical not, -a tests for logical and, and -o tests for logical or.
8)Sed Important Option.
-i | Insert | #sed -i '5i/JESUS' sed-test.txt Insert Word in 5th Line. | |
-d | Delete | #sed 5d -i File-Name | |
-e | Expression | ||
-s | Search | ||
-g | Global | ||
-n 10p | Print 10th Line | -n "2~3p” 2nd line, 5th line,8th line. | |
-w | Word | ||
-n |
9)Linux System Call Process
fork() | To Create New Process |
exec() | Execute New Program In Process |
wait() | Wait Until created process is completed. |
exit() | Exit Process Execution. |
getpid() | Get the Process ID of Current Process. |
getppid() | Get Parent Process Identifier. |
nice() | Existing Priority of process. |
brk() | Increase / Decrease Data Segment Size of process. |
10)Shell Script Passing Argument Argument
$# | Count Total No of Passed Argument. |
$0 | Script Name[./script $0 $1] here script is $0 |
$1 | Argument |
$$ | Process ID of Current Executing Process. |
$! | Which process recent went to background |
$? | Give the status of last executed Command. |
$@ $* | Display all the command Line Argument. |
11)Comparison Operation.
-lt | Less Than |
-gt | Greater Than |
-eq | Equal |
-ne | Not Equal |
-ge | Greater Than Equal |
-le | Less Than Equal |
0 Comments