xxxxxxxxxx
#!/bin/bash
# Define the directory path
directory="/path/to/your/directory"
# Calculate the timestamp for 2 days ago
two_days_ago=$(date -d "2 days ago" +%s)
# Iterate through files in the directory
for file in "$directory"/*; do
# Check if the file is a regular file
if [ -f "$file" ]; then
# Get the file's creation timestamp
file_timestamp=$(date -r "$file" +%s)
# Compare the timestamps
if [ "$file_timestamp" -lt "$two_days_ago" ]; then
# Delete the file
rm "$file"
echo "Deleted: $file"
fi
fi
done
xxxxxxxxxx
#!/bin/bash
# Define the directory path
directory="/path/to/your/directory"
# Calculate the timestamp for 2 days ago
two_days_ago=$(date -d "2 days ago" +%s)
# Iterate through files in the directory
for file in "$directory"/*; do
# Check if the file is a regular file
if [ -f "$file" ]; then
# Get the file's creation timestamp
file_timestamp=$(date -r "$file" +%s)
# Compare the timestamps
if [ "$file_timestamp" -lt "$two_days_ago" ]; then
# Delete the file
rm "$file"
echo "Deleted: $file"
fi
fi
done
xxxxxxxxxx
#!/bin/bash
# Define the directory path
directory="/path/to/your/directory"
# Calculate the timestamp for 2 days ago
two_days_ago=$(date -d "2 days ago" +%s)
# Iterate through files in the directory
for file in "$directory"/*; do
# Check if the file is a regular file
if [ -f "$file" ]; then
# Get the file's creation timestamp
file_timestamp=$(date -r "$file" +%s)
# Compare the timestamps
if [ "$file_timestamp" -lt "$two_days_ago" ]; then
# Delete the file
rm "$file"
echo "Deleted: $file"
fi
fi
done
xxxxxxxxxx
#!/bin/bash
# Define the directory path
directory="/path/to/your/directory"
# Calculate the timestamp for 2 days ago
two_days_ago=$(date -d "2 days ago" +%s)
# Iterate through files in the directory
for file in "$directory"/*; do
# Check if the file is a regular file
if [ -f "$file" ]; then
# Get the file's creation timestamp
file_timestamp=$(date -r "$file" +%s)
# Compare the timestamps
if [ "$file_timestamp" -lt "$two_days_ago" ]; then
# Delete the file
rm "$file"
echo "Deleted: $file"
fi
fi
done