I am new to Unix scrptingscripting.
I want to rename a file based on a matching string in the first line (i.e. line starting with HDRHDR).
I have a text file (File.txtFile.txt) which looks like below:
HDR##############################1234###
########################################
########################################
HDR##############################1234###
########################################
########################################
Below is my code,. How can I be more specific in my code to check only the first line in the file, which startingstarts with HDRHDR and havinghas the pattern 12341234 or 5678.5678?
if grep -o "1234" File.txt
then mv File.txt Pattern1.txt
echo "File with pattern1 received..."
elif grep -o "5678" File.txt
then mv File.txt Pattern2.txt
echo "File with pattern2 received..."
else
echo "File have no matching pattern..."
fi