#How to create executeable script?
10 messages · Page 1 of 1 (latest)
Just just create a file.
For example with touch test.sh
touch will create a (empty) file if it doesn't exist by default.
Write your code with your favorite editor like nano
Then make sure to set the executable flag on it with chmod u+x <file name>
That will give the [u]ser who owns the file the right to e[x]ecute it.
But if how execute its like ```sh
~$ someFiles.sh
Um sorry if my engglish bad
To run a file you do . ./someFile.sh
See: https://ss64.com/bash/source.html
For more information.
you can also use echo to write to files
example: echo "echo HELLO THERE!!" >> file.sh
there's cat tho
cat > file.sh << EOF
#!/usr/bin/env bash
echo "Hello World using *cat*"
EOF
HEREDOCS are kind of clumsy for simple appending from the command line.