Bash
Referencias
Quitar permisos de cuarentena en mac os
> find . -type d -exec xattr -d com.apple.quarantine {} \;
> find . -type f -exec xattr -d com.apple.quarantine {} \;
Buscar fichero que cumplan un patrón en el nombre y eliminarlos
Cuidado que borra sin preguntar!!!
find . -name "*2021-01-02*" -delete
RESIZE - Redimiensionar imágenes
> for file in *.jpg; do convert $file -resize 1140 $file; done
CROP - Recortar imágenes
> for file in *.jpg; do convert $file -gravity Center -crop 1140x488+0+0 $file; done
Operaciones con ficheros
Bash File Testing
- -b filename - Block special file
- -c filename - Special character file
- -d directoryname - Check for directory Existence
- -e filename - Check for file existence, regardless of type (node, directory, socket, etc.)
- -f filename - Check for regular file existence not a directory
- -G filename - Check if file exists and is owned by effective group ID
- -G filename set-group-id - True if file exists and is set-group-id
- -k filename - Sticky bit
- -L filename - Symbolic link
- -O filename - True if file exists and is owned by the effective user id
- -r filename - Check if file is a readable
- -S filename - Check if file is socket
- -s filename - Check if file is nonzero size
- -u filename - Check if file set-user-id bit is set
- -w filename - Check if file is writable
- -x filename - Check if file is executable
How to use:
#!/bin/bash file=./file if [ -e "$file" ]; then echo "File exists" else echo "File does not exist" fi # A test expression can be negated by using the ! operator #!/bin/bash file=./file if [ ! -e "$file" ]; then echo "File does not exist" else echo "File exists" fi
Referencias