'Bash script question. Can someone explain to me pls?
In the Bash script, write a simple program that first creates a new file called myfile.txt, then append the string "Hello world" to it. Then print out the size in bytes of myfile.txt.
Solution 1:[1]
First write the command with .sh extension and save it then run it on your terminal with bash ./fileName.sh
The contents of fileName.sh (or any other name you want to call it) are:
#!/bin/bash
touch myfile.txt
str="Hello World"
echo $str >> myfile.txt
echo ${#str}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David C. Rankin |
