How to run the files in Linux shell scipt?

I have a homework and I tried to work on this but unable to find the solution. Can someone help me how to resolve the issue.

I have a package file and it contains text file as prod.ame300_000001.101414145111.A.txt.
In the text file it contains pdf file (222222222|ZRF|2008.pdf|2008|01/29/2009|001|B|C|C)

Step1:
I have to check the index file is for A file or B file.

Step 2:
Read the first line of the original index file.

Step 3:
Read the 9th character of the line and check if the character is �|� or not

Step 4:
Based on the above, if it is �|�, it means the package is for A file, if not, it is for B file.

Step5:
Create a variable named �isA� and assign �true� or �false� value based on the above condition.

Please find the below code I have tried:
if [ -f "$indexFile" ]
then
echo "A"$indexFile" exist."
FIRSTLINE=`head -n 1 $indexFile

while read -r line
do
id = cut -c 9 $FIRSTLINE
echo $id
done < "$indexFile"

else
echo "A" $indexFile" does not exist"

Again... PLEASE do not post this in the CONTACT forums, but in the technical forums.

Also, do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.

1 Like