🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Shell script to add and commit in 10 files at a time and push


#!/bin/bash

# Set the desired commit message
COMMIT_MESSAGE="Batch commit"

# Specify the number of files to process in each batch
BATCH_SIZE=10

# Set the maximum file size in bytes (99 MB)
MAX_FILE_SIZE=$((99 * 1024 * 1024))

# Get the list of modified files
MODIFIED_FILES=$(git status --porcelain | awk '{print $2}')

# Count the total number of modified files
TOTAL_FILES=$(echo "$MODIFIED_FILES" | wc -l)

# Loop through the modified files in batches
for ((i = 1; i <= TOTAL_FILES; i += BATCH_SIZE)); do
  # Get the files for the current batch
  BATCH_FILES=$(echo "$MODIFIED_FILES" | awk "NR >= $i && NR < $i + $BATCH_SIZE")

  # Filter out files larger than the maximum size
  VALID_FILES=""
  for FILE in $BATCH_FILES; do
    FILE_SIZE=$(stat -c%s "$FILE")
    if (( FILE_SIZE <= MAX_FILE_SIZE )); then
      VALID_FILES+=" $FILE"
    fi
  done

  if [[ -n "$VALID_FILES" ]]; then
    # Add the valid files to the staging area
    git add $VALID_FILES

    # Commit the changes with the specified message
    git commit -m "$COMMIT_MESSAGE"

    # Push the changes to the remote repository
    git push origin

    # Clear the staging area
    git reset HEAD
  fi
done
Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x