text
stringlengths 0
2.87M
|
---|
#!/bin/bash |
# Set the target folder size limit |
limit=10485760 # 10 GB in KB |
# Prompt the user to enter the target folder |
read -p "Enter the path of the target folder: " folder |
# Check if the entered folder exists |
if [ ! -d "$folder" ]; then |
echo "Error: The specified folder does not exist." |
exit 1 |
fi |
# Calculate the current size of the folder |
size=$(du -s "$folder" | awk '{print $1}') |
# Loop until the folder size is less than the limit |
while [ $size -gt $limit ]; do |
# Find the oldest file in the folder |
oldest=$(find "$folder" -type f -printf '%T@ %p\n' | sort -n | head -1 | cut -d' ' -f2) |
# Delete the oldest file |
rm "$oldest" |
# Recalculate the folder size |
size=$(du -s "$folder" | awk '{print $1}') |
done |
# Find the oldest subfolder in the folder |
oldest=$(find "$folder" -type d -printf '%T@ %p\n' | sort -n | head -1 | cut -d' ' -f2) |
# Delete the oldest subfolder |
rm -r "$oldest" |
echo "The folder is now smaller than $limit KB." |
Dieses Skript verwendet den Befehl du (disk usage), um die Größe des Zielordners zu berechnen, und den Befehl find zur Suche nach den ältesten Dateien und Unterordnern. Der Befehl sort und head werden verwendet, um die älteste Datei oder den ältesten Unterordner zu finden. Schließlich wird die älteste Datei oder der älteste Unterordner mit rm bzw. rm -r gelöscht. |
Verwenden Sie dieses Skript auf eigene Gefahr und stellen Sie sicher, dass Sie eine Backup-Kopie aller Daten haben, die Sie löschen möchten.<kinrel><user>Puedes programarme en JAVA un Tres en Raya con Interfaz por Consola. Necesitaría un menú donde haya 3 opciones, la primera que sea que puedo jugar contra otro jugador, la segunda que sea que puedo jugar contra una falsa IA, y la tercera para cerrar el programa.<user><kinrel>Claro, aquí te muestro una implementación simple del juego "Tres en Raya" en Java con una interfaz por consola: |
import java.util.Scanner; |
public class TresEnRaya { |
static Scanner scan = new Scanner(System.in); |
static char[][] tablero = {{' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '}}; |
static int fila, columna; |
static char turno = 'X'; |
public static void main(String[] args) { |
while (true) { |
menu(); |
int opcion = scan.nextInt(); |
switch (opcion) { |
case 1: |
jugarContraOtroJugador(); |
break; |
case 2: |
jugarContraIA(); |
break; |
case 3: |
System.out.println("Gracias por jugar."); |
System.exit(0); |
break; |
default: |
System.out.println("Opción inválida. Intenta de nuevo."); |
} |
} |
} |
public static void menu() { |
System.out.println("Tres en Raya"); |
System.out.println("1. Jugar contra otro jugador"); |
System.out.println("2. Jugar contra IA"); |
System.out.println("3. Salir"); |
System.out.print("Selecciona una opción: "); |
} |
public static void jugarContraOtroJugador() { |
System.out.println("Comienza el juego. Tu turno es X."); |
while (true) { |
mostrarTablero(); |
moverJugador(); |
if (hayGanador(turno)) { |
System.out.println("El ganador es " + turno + "."); |
break; |
} |
if (tableroLleno()) { |
System.out.println("Empate."); |
break; |
} |
cambiarTurno(); |
} |
reiniciarTablero(); |
} |
public static void jugarContraIA() { |
System.out.println("Comienza el juego. Tu turno es X."); |
while (true) { |
mostrarTablero(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.