bellos/bellos_scripts/file_operations.bellos
2024-10-05 11:54:36 -04:00

45 lines
906 B
Plaintext

#!/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 "\nReading test file:"
read test.txt
# Append to the file
echo "\nAppending to test file..."
append test.txt "This is a new line"
# Read the updated contents
echo "\nReading updated test file:"
read test.txt
# Write to a new file
echo "\nWriting to a new file..."
write new_file.txt "This is a new file"
# Read the new file
echo "\nReading new file:"
read new_file.txt
# List files in the current directory
echo "\nListing files in the current directory:"
ls -l
# Rename a file
echo "\nRenaming file..."
mv new_file.txt renamed_file.txt
# Delete files
echo "\nDeleting files..."
rm test.txt renamed_file.txt
# List files again to confirm deletion
echo "\nListing files after deletion:"
ls -l