bellos/bellos_scripts/file_operations.bellos

45 lines
888 B
Plaintext
Raw Normal View History

2024-09-24 22:39:42 +00:00
#!/usr/bin/env bellos
# File: file_operations.bellos
# Demonstrating file operations
2024-10-03 04:14:47 +00:00
# Create a test file
echo "Creating test file..."
2024-10-05 15:54:36 +00:00
write test.txt "Hello, World!"
2024-09-24 22:39:42 +00:00
2024-10-03 04:14:47 +00:00
# Read the contents of the file
2024-10-21 07:14:41 +00:00
echo "Reading test file:"
2024-10-05 15:54:36 +00:00
read test.txt
2024-09-24 22:39:42 +00:00
2024-10-03 04:14:47 +00:00
# Append to the file
2024-10-21 07:14:41 +00:00
echo "Appending to test file..."
2024-10-05 15:54:36 +00:00
append test.txt "This is a new line"
2024-09-24 22:39:42 +00:00
2024-10-03 04:14:47 +00:00
# Read the updated contents
2024-10-21 07:14:41 +00:00
echo "Reading updated test file:"
2024-10-05 15:54:36 +00:00
read test.txt
2024-10-03 04:14:47 +00:00
# Write to a new file
2024-10-21 07:14:41 +00:00
echo "Writing to a new file..."
2024-10-05 15:54:36 +00:00
write new_file.txt "This is a new file"
2024-10-03 04:14:47 +00:00
# Read the new file
2024-10-21 07:14:41 +00:00
echo "Reading new file:"
2024-10-05 15:54:36 +00:00
read new_file.txt
2024-10-03 04:14:47 +00:00
# List files in the current directory
2024-10-21 07:14:41 +00:00
echo "Listing files in the current directory:"
2024-10-03 04:14:47 +00:00
ls -l
# Rename a file
2024-10-21 07:14:41 +00:00
echo "Renaming file..."
2024-10-03 04:14:47 +00:00
mv new_file.txt renamed_file.txt
# Delete files
2024-10-21 07:14:41 +00:00
echo "Deleting files..."
2024-10-03 04:14:47 +00:00
rm test.txt renamed_file.txt
2024-09-24 22:39:42 +00:00
2024-10-03 04:14:47 +00:00
# List files again to confirm deletion
2024-10-21 07:14:41 +00:00
echo "Listing files after deletion:"
2024-10-03 04:14:47 +00:00
ls -l