Skip to main content
Solved

Scripting - Getting a line from txt file


Forum|alt.badge.img+4

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.

Best answer by Hugonaut

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
View original
Did this topic help you find an answer to your question?

3 replies

Hugonaut
Forum|alt.badge.img+15
  • Esteemed Contributor
  • 574 replies
  • Answer
  • November 20, 2019

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

Forum|alt.badge.img+4
  • Author
  • New Contributor
  • 7 replies
  • November 20, 2019

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


Hugonaut
Forum|alt.badge.img+15
  • Esteemed Contributor
  • 574 replies
  • November 21, 2019

@odnlinx You're welcome glad it helped!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings