Using 'defaults read' and storing the output in a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using 'defaults read' and storing the output in a variable
# 1  
Old 11-14-2007
Question Using 'defaults read' and storing the output in a variable

Hi all,

I'm creating a script which uses 'defaults read' to retrieve details from an Info.plist like this;

defaults read "/Path/Contents/Info" CFBundleShortVersionString

This works fine in Terminal and returns the expected values.

Is it possible to use this command in a script, and store the output into a variable?

Many thanks in advance Smilie

Dave
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

2. Shell Programming and Scripting

Storing command output in a variable and using cut/awk

Hi, My aim is to get the md5 hash of a file and store it in a variable. var1="md5sum file1" $var1 The above outputs fine but also contains the filename, so somthing like this 243ASsf25 file1 i just need to get the first part and put it into a variable. var1="md5sum file1"... (5 Replies)
Discussion started by: JustALol
5 Replies

3. Shell Programming and Scripting

Defaults read/write question

OSX 10.9 How does "defaults" know where to look for .plists? To expand: defaults read com.apple.finder is located in ~/Library/Preferences but, defaults read com.apple.mail is located in ~/Library/Containers/com.apple.mail/Data/Library/Preferences/com.apple.mail.plist So my question... (0 Replies)
Discussion started by: sudo
0 Replies

4. Shell Programming and Scripting

Storing output into a variable

My script below seems to be choking because I need the the output of the find command to be stored as a variable that can then be called by used lower in the script. #!/bin/bash cd "/resumes_to_be_completed" var1=find . -mmin -1 -type f \( -name "*.doc" -o -name "*.docx" \)... (1 Reply)
Discussion started by: binary-ninja
1 Replies

5. Shell Programming and Scripting

storing output from echo & cut into variable

Hi All, Hope someone can advise here as I have been struggling to find a syntax that works here. I have tried a stack of combination I have seed in the forums but I think because I have needed to use "" and `` in the statments another method is found. I am reading in lines with the following... (1 Reply)
Discussion started by: nkwilliams
1 Replies

6. UNIX for Dummies Questions & Answers

Storing lines of output into a script variable

I'm sure this is a simple thing but I can't figure it out. In a script that I'm writing, I'd like to be able to store each line of output from "ls -l" into a variable. Ultimately I'd like to end up with something like: for a in `ls -l` do something with $a doneBut that's reading each... (2 Replies)
Discussion started by: ewoods
2 Replies

7. UNIX Desktop Questions & Answers

problem while storing the output of awk to variable

Hi, i have some files in one directory(say some sample dir) whose names will be like the following. some_file1.txt some_file2.txt. i need to get the last modified file size based on file name pattern like some_ here i am able to get the value of the last modified file size using the... (5 Replies)
Discussion started by: eswarreddya
5 Replies

8. UNIX for Dummies Questions & Answers

Using defaults read to get value from plist

Hi there, I'm trying to retrieve a value from a plist file, which I have done before with no problems, however this plist file looks a little different.... Normally it's like this; <plist version="1.0"> <dict> key>KeyName</key> <string>blah</string> I want the value of KeyName, so... (1 Reply)
Discussion started by: davewg
1 Replies

9. UNIX for Dummies Questions & Answers

Storing the output into a variable

Hi unix gurus, I am trying to store the result of a command into a variable. But it is not getting stored. x='hello' y=echo $x | wc -c but it is giving the output as 0(zero) Pls help me its very urgent (7 Replies)
Discussion started by: ravi raj kumar
7 Replies

10. Shell Programming and Scripting

storing output of awk in variable

HI I am trying to store the output of this awk command awk -F, {(if NR==2) print $1} test.sr in a variable when I am trying v= awk -F, {(if NR==2) print $1} test.sr $v = awk -F, {(if NR==2) print $1} test.sr but its not working out . Any suggestions Thanks Arif (3 Replies)
Discussion started by: mab_arif16
3 Replies
Login or Register to Ask a Question
AGVTOOL(1)						    BSD General Commands Manual 						AGVTOOL(1)

NAME
agvtool -- Apple-generic versioning tool for Xcode projects SYNOPSIS
agvtool what-version | vers [-terse] agvtool [-noscm | -usecvs | -usesvn] next-version | bump [-all] agvtool [-noscm | -usecvs | -usesvn] new-version [-all] versionNumber agvtool [-noscm | -usecvs | -usesvn] tag [-force | -F] [-noupdatecheck | -Q] [-baseurlfortag] agvtool what-marketing-version | mvers [-terse | -terse1] agvtool [-noscm | -usecvs | -usesvn] new-marketing-version version DESCRIPTION
agvtool helps speed up common operations for Xcode projects that use the Apple Generic Versioning system. You enable versioning support by setting up some build settings in your project. Build Settings The settings used by the apple-generic versioning system are as follows: VERSIONING_SYSTEM This must be set to ``apple-generic'' at the project level to enable versioning. CURRENT_PROJECT_VERSION This setting defines the the current version of the project. The value must be a integer or floating point number like 57 or 365.8. DYLIB_CURRENT_VERSION This setting defines the the current version of any framework built by the project. Like CURRENT_PROJECT_VERSION the value must be an integer or floating point number like 57 or 365.8. By default it is set to ``$(CURRENT_PROJECT_VERSION)''. VERSION_INFO_PREFIX Used as a prefix for the name of the version info symbol in the generated versioning source file. If you prefix your exported symbols you will probably want to set this to the same prefix. VERSION_INFO_SUFFIX Used as a suffix for the name of the version info symbol in the generated versioning source file. This is rarely used. VERSION_INFO_BUILDER This defines a reference to the user performing a build to be included in the generated stub, and defaults to the value of the USER environment variable. VERSION_INFO_EXPORT_DECL This defines a prefix string for the version info symbol declaration in the generated stub. This can be used, for example, to add an optional 'export' keyword to the version symbol declaration. This should rarely be changed. VERSION_INFO_FILE Used to specify a name for the source file that will be generated and compiled into your product. By default this is set to ``$(PRODUCT_NAME)_vers.c''. To enable Apple Generic Versioning, then, you must set up at least the VERSIONING_SYSTEM and CURRENT_PROJECT_VERSION project build settings for each project you want to be versioned. The target of a versioned project will have two global variables generated and linked into your product. One is of type double and is simply the CURRENT_PROJECT_VERSION. The other is a version string which is formatted to be compatible with what(1). These variables are available for use in your code. Projects with multiple targets are required to have the same CURRENT_PROJECT_VERSION for each target. The easiest way to achieve this is to set CURRENT_PROJECT_VERSION at the project level. Usage agvtool should be invoked with the working directory set to your project directory (the folder containing your .xcodeproj project file). agvtool pays attention to the following defaults for CVS usage: CVSEnabled and CVSToolPath. If CVSEnabled is set to YES then agvtool will perform certain CVS operations like committing modified project files and performing tagging operations. You can set this default by issuing the following command: defaults write agvtool CVSEnabled YES The sense of this default can be overidden by supplying an explicit -noscm (which turns off CVS and Subversion usage), -usecvs (which turns on CVS usage and turns off Subversion usage), or -usesvn (which turns off CVS usage and turns on Subversion usage). Set CVSToolPath to point to the location of the cvs tool to use. If this default is not set then agvtool will use /usr/bin/ocvs if it exists. Otherwise /usr/bin/cvs will be used. You can set this default by issuing the following command: defaults write agvtool CVSToolPath pathToCVS agvtool pays attention to the following defaults for Subversion usage: SVNEnabled and SVNToolPath. If SVNEnabled is set to YES then agvtool will perform certain Subversion operations like committing modified project files and performing tagging operations. You can set this default by issuing the following command: defaults write agvtool SVNEnabled YES The sense of this default can be overidden by supplying an explicit -noscm (which turns off CVS and Subversion usage), -usecvs (which turns on CVS usage and turns off Subversion usage), or -usesvn (which turns off CVS usage and turns on Subversion usage). Set SVNToolPath to point to the location of the svn tool to use. If this default is not set then agvtool will use /usr/local/bin/svn if it exists. You can set this default by issuing the following command: defaults write agvtool SVNToolPath pathToSVN Commands And Options what-version | vers [-terse] Prints out the current version number of the project. The -terse option can be used to limit the output to the version number only. next-version | bump [-all] Increments the version numbers of all versioned targets to the next highest integral value. For example, 54 will change to 55 and 234.6 will change to 235. The CURRENT_PROJECT_VERSION and the DYLIB_CURRENT_VERSION will be updated. The -all option will also update the CFBundleVersion Info.plist key. If CVS support is enabled, the modified project file will be committed. new-version [-all version] Sets the version numbers of all versioned targets to the given version. The CURRENT_PROJECT_VERSION and the DYLIB_CURRENT_VERSION will be updated. The -all option will also update the CFBundleVersion Info.plist key. If CVS support is enabled, the modified project file will be committed. tag [-force | -F] [-noupdatecheck | -Q] [-baseurlfortag] Create a new tag projectname-currentversion where projectname is the name of the Xcode project file (without the extension) and currentversion is the CURRENT_PROJECT_VERSION with any '.' transformed into '~' (since CVS does not allow dots in tag names). The -force or -F option will add a -F to the tag operation. The -noupdatecheck or -Q option skips the cvs update usually done prior to tagging to ensure that there are no uncommitted changes. The -baseurlfortag option can be used to provide a URL that points to the directory to place the "tag" in when using Subversion. This overrides the SVNBaseTagURL default. This option is ignored if Subversion is not being used. Note: This command will only function if CVS or Subversion support is enabled. what-marketing-version | mvers [-terse] Prints the current marketing version of the project. For native targets, a marketing version is listed for each Info.plist file found. For Jambase targets a marketing version is shown if a common value is found. The marketing version is the CFBundleShortVersionString Info.plist key. This is often a totally different version determined by product marketing folks. The -terse option will limit the output to the version number only. The -terse1 option will limit the output to the first version number found, and only display the version number. new-marketing-version version Sets the marketing version numbers of all versioned targets to the given version number. The marketing version is the CFBundleShortVersionString Info.plist key. This is often a totally different version determined by product marketing folks. If CVS support is enabled, the modified project file will be committed. Do not use this command on a project with targets that track different marketing versions. Mac OS X April 4, 2006 Mac OS X