Scripting - Getting a line from txt file

odnlinx
New Contributor II

Hello,

I'm very new to scripting and need help getting a specific line from a txt file. I need to get an Adobe Challenge Key for our License renewal process. I figured out a way of packaging the terminal tool kit and running a script to get a text file as the output. Now I'm struggling to figure out a way to get key back from each computer. I just need the fourth line.

36d4cfffbf6c4afdb62cd21f007f8963

1 ACCEPTED SOLUTION

Hugonaut
Valued Contributor II

I think this is what you want...the 1st line in the script creates a blank .txt file in a path you so choose.

Then once the blank .txt file is created, The second line outputs the 4th Line from the Adobe_License.txt & writes it into the blank .txt file.

With this you can do what ever you want, you can create an extension attribute & echo blank .txt files contents so all the computers checking in will display the key in your jamf inventory, etc

#!/bin/sh

sudo touch /Path/to/Blank.txt

sed -n 4p /Users/Shared/Adobe_License ToolKit/Adobe_License.txt > /Path/to/Blank.txt
________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

View solution in original post

3 REPLIES 3

Hugonaut
Valued Contributor II

I think this is what you want...the 1st line in the script creates a blank .txt file in a path you so choose.

Then once the blank .txt file is created, The second line outputs the 4th Line from the Adobe_License.txt & writes it into the blank .txt file.

With this you can do what ever you want, you can create an extension attribute & echo blank .txt files contents so all the computers checking in will display the key in your jamf inventory, etc

#!/bin/sh

sudo touch /Path/to/Blank.txt

sed -n 4p /Users/Shared/Adobe_License ToolKit/Adobe_License.txt > /Path/to/Blank.txt
________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

odnlinx
New Contributor II

@Hugonaut That definitely helped me out. Thanks for the help.

Hugonaut
Valued Contributor II

@odnlinx You're welcome glad it helped!

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month