but every new line will be taken as a rule hence it will get difficult to write a conditional or structure etc which constitutes more than one line within itself..
for
clean: if ( rm *.o ) then echo cleaned else echo already cleaned
will give errors...
Solution:
clean: ./script
now include all statements/structures in this script make it "chmod +x script"
now use : make clean it may now also be done under: ./script
if (sudo apt-get check) then echo echo All dependencies are good
else echo echo Checking broken dependencies echo if (sudo apt-get install -f) then echo All broken dependencies have been fixed..!! else echo Unable to fix:Manual fix required fi fi
2.) To backup all data (C_programs in this case) to windows drive by mounting the drive and then unmounting the same..
#! /bin/bash
if (sudo umount /dev/sda6) then sudo mount /dev/sda6 /mnt sudo cp -r -f -u -v /home/xenial-xerus/Desktop/C_programs /mnt/C_Programs_Backup sudo umount /dev/sda6 echo echo "Backup Done. We are safe !!"
else clear sudo mount /dev/sda6 /mnt sudo cp -r -f -u -v /home/xenial-xerus/Desktop/C_programs /mnt/C_Programs_Backup sudo umount /dev/sda6 echo echo "Backup Done. We are safe !!" fi
#SO AT THE END OF THE DAY WE SAY: # ./update && ./backup ---->> TO UPDATE AND BACKUP
for file in $(ls *.h) do ci $file done for file in $(ls *.c) do ci $file done for file in $(ls *.h,v) do co $file done for file in $(ls *.c,v) do co $file done if ( make ) then echo "Make Sucessfull" read -n1 -p "Do you want to run application(y/n):" echo if [ $REPLY = y ] then ./ll else echo "Good Bye" fi fi read -n1 -p "Do you want to edit the file (y/n):" if [ $REPLY = y ] then for file in $(ls *.h,v) do co -l $file done for file in $(ls *.c,v) do co -l $file done
bash "Assignment and Comparison" syntax differences
#!/bin/bash echo "yes or no(y/n)" read -n1 if test $REPLY='y' is same as if[$REPLY='y']space here is mandatory for comparasion .Other wise it will be treated as assignment operator.
then echo "You are invited" else echo "Have a nice day" fi