Hello,
I'm just starting to use shell script so I'm probably approaching this wrong.
I'm referencing txt files in a directory then reading the file line by line and would like to save part of a specific line.
The line I'm interested in looks like:
Here is the main section of the script:
I'm trying to get it working in sections.
Ultimately I want the text to the right of the equal sign of the job name section to appear as the email subject.
How do I save the cut portion to a variable?
Thanks.
If at first you don't succeed, then sky diving wasn't meant for you!
I'm just starting to use shell script so I'm probably approaching this wrong.
I'm referencing txt files in a directory then reading the file line by line and would like to save part of a specific line.
The line I'm interested in looks like:
Job Name = company:jobname
Here is the main section of the script:
Code:
for xfile in *.txt
do
echo $xfile
while read line
do
linetxt=$line
# Look at the first 8 characters of the line
# WORKS echo $linetxt|cut -c1-8
# DOESN'T WORK extrtxt=$linetxt|cut -c1-8
# echo $extrtxt
# if [ '$extrtxt' = 'Job Name' ]; then
# echo $jobname
# fi
done < $xfile
# mail -s "subject name" email@test.com < $xfile
done
I'm trying to get it working in sections.
Ultimately I want the text to the right of the equal sign of the job name section to appear as the email subject.
How do I save the cut portion to a variable?
Thanks.
If at first you don't succeed, then sky diving wasn't meant for you!