File Handling using Shell Scripts

In this article,I will explain File Handling using Shell Scripts.

Example: Add line at beginning of file.

Filename: test.sh

#!/bin/bash

read -p "File Name: " file   
if [ ! -e "$file" ]
then   
echo "File $file not found."
exit 50
fi

read -p "Name: " name
cat - $file <<<$name > $file.new
exit 0