change_ver.sh 603 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # Check if $TAG_NAME is set
  3. if [ -z "$TAG_NAME" ]; then
  4. echo "Error: \$TAG_NAME must be set"
  5. exit 1
  6. fi
  7. # Extract the version from $TAG_NAME
  8. version="${TAG_NAME##v}"
  9. # Loop through all files in the current directory
  10. for file in *; do
  11. # Check if the file is a regular file
  12. if [ -f "$file" ]; then
  13. # Make a temporary copy of the file
  14. cp "$file" "$file.tmp"
  15. # Perform the replacement
  16. sed "s/fap_version=\"[0-9]*\.[0-9]*\"/fap_version=\"$version\"/" "$file.tmp" > "$file"
  17. # Remove the temporary file
  18. rm "$file.tmp"
  19. fi
  20. done