23 lines
423 B
Plaintext
23 lines
423 B
Plaintext
#!/usr/bin/env bellos
|
|
|
|
# File: file_operations.bellos
|
|
# Demonstrating file operations
|
|
|
|
# Writing to a file
|
|
write test.txt "This is a test file"
|
|
append test.txt "Adding another line"
|
|
|
|
# Reading from a file
|
|
echo "Contents of test.txt:"
|
|
read test.txt
|
|
|
|
# Using a loop to read file line by line
|
|
echo "Reading file line by line:"
|
|
for line in $(read_lines test.txt)
|
|
do
|
|
echo "Line: ${line}"
|
|
done
|
|
|
|
# Cleaning up
|
|
delete test.txt
|