I need to create a text file (unless it already exists) and write a new line to the file all using bash.
I\'m sure it\'s simple, but could anyone explain this to me?
#!/bin/bash
file_location=/home/test/$1.json
if [ -e $policy ]; then
echo "File $1.json already exists!"
else
cat > $file_location <
This code checks if the given JSON file of the user is present in test home directory or not. If it's not present it will create it with the content. You can modify the file location and content according to your needs.