Skip to main content
Solved

Scripting - Getting a line from txt file

  • November 20, 2019
  • 3 replies
  • 38 views

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

3 replies

Hugonaut
Forum|alt.badge.img+15
  • Esteemed Contributor
  • 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
  • November 20, 2019

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


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

@odnlinx You're welcome glad it helped!