bellos/bellos_scripts/file_operations.bellos
2024-10-21 03:14:41 -04:00

45 lines
888 B
Plaintext
Executable File

#!/usr/bin/env bellos
# File: file_operations.bellos
# Demonstrating file operations
# Create a test file
echo "Creating test file..."
write test.txt "Hello, World!"
# Read the contents of the file
echo "Reading test file:"
read test.txt
# Append to the file
echo "Appending to test file..."
append test.txt "This is a new line"
# Read the updated contents
echo "Reading updated test file:"
read test.txt
# Write to a new file
echo "Writing to a new file..."
write new_file.txt "This is a new file"
# Read the new file
echo "Reading new file:"
read new_file.txt
# List files in the current directory
echo "Listing files in the current directory:"
ls -l
# Rename a file
echo "Renaming file..."
mv new_file.txt renamed_file.txt
# Delete files
echo "Deleting files..."
rm test.txt renamed_file.txt
# List files again to confirm deletion
echo "Listing files after deletion:"
ls -l