I looked some other posts and learnt to match file extension in the following way but why my code is not working? Thanks.

<br>

  1 #!/bin/sh
  2 
  3 for i in `ls`
  4 do
  5     if [[ "$i" == *.txt ]]
  6     then
  7         echo "$i is .txt file"
  8     else
  9         echo "$i is NOT .txt file"
 10     fi
 11 done


Bash alias to wrap around Git commit

I am trying to write a bash alias to wrap around a Git commit command.

I am trying to write a bash alias to wrap around a Git commit command.

Here is what my typical Git commit looks like. git commit -am 'Comments in here'

Here is what I have attempted to write as an alias (which would go inside my .bashrc file), so I don't have to write out the whole command every time.

comm(){

git commit -am $1

}

Then I would call it like this: comm 'Comments in here'

However I keep getting this error: fatal: Paths with -a does not make sense.

Anything I'm missing here?

Remove Database settings of django using bash script

I am trying to create a bash script to create a boilerplate django project that suits for my company. I need to delete the DATABASES in settings and append new one. The DATABASES is a python dictionary with structure

I am trying to create a bash script to create a boilerplate django project that suits for my company. I need to delete the DATABASES in settings and append new one. The DATABASES is a python dictionary with structure

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

For this I tried something like this

sed -i -e "/DATABASES = {/,/}/d" settings.py

But it resulted in a trailing }.

The output is

}

I understood that the pattern it matches is for the first curly braces but not the second. What should be the approach for this.

Bash: Array empty outside of the for loop

I'm creating a script to rotate my backups, one important part of this script is to find the files based on certain criteria and then move them or erase them.

I'm creating a script to rotate my backups, one important part of this script is to find the files based on certain criteria and then move them or erase them.

I've got the loop going, but the Array (path_array), can't be used outside the loop. I've read several posts about this, but not sure how the answers apply to my specific case. See code below.

Thanks!!!

#!/bin/bash
anos=(2016 2017 2018 2019)
meses=(02)

meses=(01 02 03 04 05 06 07 08 09 10 11 12)
anos=(2018)

source="/volume1/NetBackup/Servers/MIA/"
destination="/volume1/NetBackup/Servers/MIA/_Archive"

######## Pasar los Files del Primer dia del Año a Archiving

for i in ${anos[@]}; do
for j in ${meses[@]}; do
month_start=$(date +$i-$j-01)
month_finish=$(date +$i-$j-02)
# echo $month_start
# echo $month_finish
path_array=(find $source -type f -not -path "*/_Archive/*" -newermt $month_start ! -newermt $month_finish | cut -sd / -f 6-)
# echo $path_array

    # echo Archivos año: $i mes: $j

    #printf '%s\n' "${path_array[@]}"
done

done

printf '%s\n' "${path_array[@]}"