Saturday 16 September 2017

conditional execution of commands in linux

if the first command is executed successfully then execute the second command in linux
example
       if the kuldeep folder is present at your working directory then this will create test.txt file in this folder.
[root@localhost~]#ls -ld kuldeep && touch kuldeep/test.txt

if the first command does not execute successfully then execute the second command in linux
example
      if the kuldeep folder is not present at your working directory then this will create it
 [root@localhost~]#ls -ld kuldeep || mkdir kuldeep

pls put your comments and suggestion.

3 comments:

  1. Right it working. Abhi check kr liya

    ReplyDelete
  2. Firtst commands execute nahi ho rahi.
    Second command ko execute karane ke baad first command execute ho rahi ha.
    In my opinion jab hum first cmd ko first time execute Kara rahe hai toh uske 1st or 2nd part mein se koi bhi execute nahi ho raha because of && Gate/operator, 1st cmd ka 2nd part tab execute hoga jab 1st part true ho.

    2nd cmd ko execute karne par uske 1st part ka error msg aata hai lekin fir bhi 2part execute ho jaata hai kyoki isme || gate/operator ka use kiya hai 1st condition false hone par bhi second condition execute ho rahi hai.

    ReplyDelete

how to set time for internet use

this will allow internet access for a particular time interval. R4(config)#int f0/0 R4(config-if)#ip nat inside R4(config-...