You are not logged in.

#1 2014-12-14 23:04:02

aligator
Member
Registered: 2013-10-07
Posts: 75

[bash] echo -n < /dev/null

hi

I found a script, with this code:

...
if [ $LOGIT -eq 1 ]
then
   echo "[LOG] Checking if backup folders exist, if not then create them."
fi

if [ -d $BACKUPDIR ]
then
   echo -n < /dev/null
else
   mkdir "$BACKUPDIR"

   if [ $LOGIT -eq 1 ]
   then
      echo "[LOG] Created Folder: $BACKUPDIR"
   fi

fi
...

but I don't understand why there is the "echo -n < /dev/null".

Offline

#2 2014-12-14 23:19:19

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 12,595
Website

Re: [bash] echo -n < /dev/null

Whoever wrote it, didn't know about conditional bangs (aka logical negation), and wanted to not do anything when a condition was true.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB