LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash script. How to join two IF in one? (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-how-to-join-two-if-in-one-74066/)

rytrom 07-19-2003 09:36 AM

Bash script. How to join two IF in one?
 
I wanna check 3 conditions all together
1. file exist
2. its extention is java
3. in first 120 lines it has $Revision word somewere


if [ -f $f ]; then
if echo "$f" | grep '.*\.java$' > /dev/null; then
if head -120 < "$f" | grep '\$Revision' > /dev/null then
...

it works Ok, but how to join them in one if? How to deal with ramifications in a more compex case?

mhearn 07-19-2003 11:14 AM

Separate the conditions with &&

if [ -e $f ] && whatever; then
fi


All times are GMT -5. The time now is 12:05 AM.